From ec76fda41319e6bc5745b1f9577f9a19ee1e92ad Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Thu, 28 Nov 2024 19:16:27 +0000 Subject: [PATCH] feat: allow for "import narwhals.stable.v1.selectors as cs" (#1459) --- narwhals/__init__.py | 2 ++ narwhals/selectors.py | 10 ++++++++++ narwhals/stable/v1/__init__.py | 2 ++ narwhals/stable/v1/selectors.py | 17 +++++++++++++++++ tests/selectors_test.py | 12 ++++++------ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 narwhals/stable/v1/selectors.py diff --git a/narwhals/__init__.py b/narwhals/__init__.py index 812956bf5..b8b02e8c3 100644 --- a/narwhals/__init__.py +++ b/narwhals/__init__.py @@ -1,6 +1,7 @@ from __future__ import annotations from narwhals import dependencies +from narwhals import dtypes from narwhals import exceptions from narwhals import selectors from narwhals import stable @@ -107,6 +108,7 @@ "concat", "concat_str", "dependencies", + "dtypes", "exceptions", "from_arrow", "from_dict", diff --git a/narwhals/selectors.py b/narwhals/selectors.py index ab23ed27e..dbb99f82c 100644 --- a/narwhals/selectors.py +++ b/narwhals/selectors.py @@ -268,3 +268,13 @@ def all() -> Expr: └─────┴─────┴───────┘ """ return Selector(lambda plx: plx.selectors.all()) + + +__all__ = [ + "by_dtype", + "numeric", + "boolean", + "string", + "categorical", + "all", +] diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py index cfea156dd..2a94b268a 100644 --- a/narwhals/stable/v1/__init__.py +++ b/narwhals/stable/v1/__init__.py @@ -28,6 +28,7 @@ from narwhals.functions import show_versions from narwhals.schema import Schema as NwSchema from narwhals.series import Series as NwSeries +from narwhals.stable.v1 import dtypes from narwhals.stable.v1.dtypes import Array from narwhals.stable.v1.dtypes import Boolean from narwhals.stable.v1.dtypes import Categorical @@ -3232,6 +3233,7 @@ def from_dict( "concat", "concat_str", "dependencies", + "dtypes", "exceptions", "from_arrow", "from_dict", diff --git a/narwhals/stable/v1/selectors.py b/narwhals/stable/v1/selectors.py new file mode 100644 index 000000000..1b630d88a --- /dev/null +++ b/narwhals/stable/v1/selectors.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +from narwhals.selectors import all +from narwhals.selectors import boolean +from narwhals.selectors import by_dtype +from narwhals.selectors import categorical +from narwhals.selectors import numeric +from narwhals.selectors import string + +__all__ = [ + "by_dtype", + "numeric", + "boolean", + "string", + "categorical", + "all", +] diff --git a/tests/selectors_test.py b/tests/selectors_test.py index 01ee1e754..8a2194caf 100644 --- a/tests/selectors_test.py +++ b/tests/selectors_test.py @@ -5,12 +5,12 @@ import pytest import narwhals.stable.v1 as nw -from narwhals.selectors import all -from narwhals.selectors import boolean -from narwhals.selectors import by_dtype -from narwhals.selectors import categorical -from narwhals.selectors import numeric -from narwhals.selectors import string +from narwhals.stable.v1.selectors import all +from narwhals.stable.v1.selectors import boolean +from narwhals.stable.v1.selectors import by_dtype +from narwhals.stable.v1.selectors import categorical +from narwhals.stable.v1.selectors import numeric +from narwhals.stable.v1.selectors import string from tests.utils import PYARROW_VERSION from tests.utils import Constructor from tests.utils import assert_equal_data