Skip to content

Commit

Permalink
chore: More Polars typing, update 'used by', link to roadmap (#1377)
Browse files Browse the repository at this point in the history
* chore: More _polars typing

* used by, roadmap
  • Loading branch information
MarcoGorelli authored Nov 14, 2024
1 parent d8d30d9 commit 666d06d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ Get started!
- [Join our community call](https://calendar.google.com/calendar/embed?src=27ff6dc5f598c1d94c1f6e627a1aaae680e2fac88f848bda1f2c7946ae74d5ab%40group.calendar.google.com)
- [Read the contributing guide](https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md)

## Used by / integrates with
## Used by

Join the party!

- [Altair](https://github.com/vega/altair/)
- [Hamilton](https://github.com/DAGWorks-Inc/hamilton/tree/main/examples/narwhals)
- [altair](https://github.com/vega/altair/)
- [marimo](https://github.com/marimo-team/marimo)
- [panel-graphic-walker](https://github.com/panel-extensions/panel-graphic-walker)
- [pymarginaleffects](https://github.com/vincentarelbundock/pymarginaleffects)
- [py-shiny](https://github.com/posit-dev/py-shiny)
- [rio](https://github.com/rio-labs/rio)
Expand Down
9 changes: 2 additions & 7 deletions docs/roadmap_and_related.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

## Roadmap

Priorities, as of September 2024, are:

- Works towards supporting projects which have shown interest in Narwhals.
- Add extra docs and tutorials to make the project more accessible and easy to get started with.
- Improve support for cuDF, which we can't currently test in CI (unless NVIDIA helps us out :wink:) but
which we can and do test manually in Kaggle notebooks.
- Define a lazy-only layer of support which can include DuckDB, Ibis, and PySpark.
See [roadmap discussion on GitHub](https://github.com/narwhals-dev/narwhals/discussions/1370)
for an up-to-date plan of future work.

## Related projects

Expand Down
21 changes: 11 additions & 10 deletions narwhals/_polars/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from narwhals.utils import Implementation

if TYPE_CHECKING:
import polars as pl
from typing_extensions import Self

from narwhals.dtypes import DType
Expand All @@ -19,7 +20,7 @@

class PolarsExpr:
def __init__(
self, expr: Any, dtypes: DTypes, backend_version: tuple[int, ...]
self, expr: pl.Expr, dtypes: DTypes, backend_version: tuple[int, ...]
) -> None:
self._native_expr = expr
self._implementation = Implementation.POLARS
Expand All @@ -29,7 +30,7 @@ def __init__(
def __repr__(self) -> str: # pragma: no cover
return "PolarsExpr"

def _from_native_expr(self, expr: Any) -> Self:
def _from_native_expr(self, expr: pl.Expr) -> Self:
return self.__class__(
expr, dtypes=self._dtypes, backend_version=self._backend_version
)
Expand Down Expand Up @@ -147,8 +148,8 @@ class PolarsExprDateTimeNamespace:
def __init__(self, expr: PolarsExpr) -> None:
self._expr = expr

def __getattr__(self, attr: str) -> Any:
def func(*args: Any, **kwargs: Any) -> Any:
def __getattr__(self, attr: str) -> Callable[[Any], PolarsExpr]:
def func(*args: Any, **kwargs: Any) -> PolarsExpr:
args, kwargs = extract_args_kwargs(args, kwargs) # type: ignore[assignment]
return self._expr._from_native_expr(
getattr(self._expr._native_expr.dt, attr)(*args, **kwargs)
Expand All @@ -161,8 +162,8 @@ class PolarsExprStringNamespace:
def __init__(self, expr: PolarsExpr) -> None:
self._expr = expr

def __getattr__(self, attr: str) -> Any:
def func(*args: Any, **kwargs: Any) -> Any:
def __getattr__(self, attr: str) -> Callable[[Any], PolarsExpr]:
def func(*args: Any, **kwargs: Any) -> PolarsExpr:
args, kwargs = extract_args_kwargs(args, kwargs) # type: ignore[assignment]
return self._expr._from_native_expr(
getattr(self._expr._native_expr.str, attr)(*args, **kwargs)
Expand All @@ -175,8 +176,8 @@ class PolarsExprCatNamespace:
def __init__(self, expr: PolarsExpr) -> None:
self._expr = expr

def __getattr__(self, attr: str) -> Any:
def func(*args: Any, **kwargs: Any) -> Any:
def __getattr__(self, attr: str) -> Callable[[Any], PolarsExpr]:
def func(*args: Any, **kwargs: Any) -> PolarsExpr:
args, kwargs = extract_args_kwargs(args, kwargs) # type: ignore[assignment]
return self._expr._from_native_expr(
getattr(self._expr._native_expr.cat, attr)(*args, **kwargs)
Expand All @@ -189,8 +190,8 @@ class PolarsExprNameNamespace:
def __init__(self, expr: PolarsExpr) -> None:
self._expr = expr

def __getattr__(self, attr: str) -> Any:
def func(*args: Any, **kwargs: Any) -> Any:
def __getattr__(self, attr: str) -> Callable[[Any], PolarsExpr]:
def func(*args: Any, **kwargs: Any) -> PolarsExpr:
args, kwargs = extract_args_kwargs(args, kwargs) # type: ignore[assignment]
return self._expr._from_native_expr(
getattr(self._expr._native_expr.name, attr)(*args, **kwargs)
Expand Down

0 comments on commit 666d06d

Please sign in to comment.