Repository: narwhals-dev/narwhals
Pull request #1459 (2024-11-28 19:03:06)

feat: allow for "import narwhals.stable.v1.selectors as cs"
<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues

- Related issue #\<issue number\>
- Closes #\<issue number\>

## Checklist

- [ ] Code follows style guide (ruff)
- [ ] Tests added
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below



Patch:
diff --git a/narwhals/__init__.py b/narwhals/__init__.py
index 812956bf..b8b02e8c 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 @@ __all__ = [
     "concat",
     "concat_str",
     "dependencies",
+    "dtypes",
     "exceptions",
     "from_arrow",
     "from_dict",
diff --git a/narwhals/selectors.py b/narwhals/selectors.py
index ab23ed27..dbb99f82 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 cfea156d..2a94b268 100644
--- a/narwhals/stable/v1/__init__.py
+++ b/narwhals/stable/v1/__init__.py
@@ -28,6 +28,7 @@ from narwhals.functions import get_level
 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 @@ __all__ = [
     "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 00000000..1b630d88
--- /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",
+]


Test patch:
diff --git a/tests/selectors_test.py b/tests/selectors_test.py
index 01ee1e75..8a2194ca 100644
--- a/tests/selectors_test.py
+++ b/tests/selectors_test.py
@@ -5,12 +5,12 @@ import pyarrow as pa
 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