Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make typing available under narwhals.stable.v1 #1130

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Oct 4, 2024

dtypes is already available

I tested this in py-shiny with a local install of narwhals, and did

diff --git a/shiny/render/_data_frame_utils/_types.py b/shiny/render/_data_frame_utils/_types.py
index 2fa1bea9..48698819 100644
--- a/shiny/render/_data_frame_utils/_types.py
+++ b/shiny/render/_data_frame_utils/_types.py
@@ -14,11 +14,11 @@ from typing import (
 
 import narwhals.stable.v1 as nw
 from htmltools import TagNode
-from narwhals.dtypes import DType as DType
-from narwhals.typing import DataFrameT as DataFrameT
-from narwhals.typing import IntoDataFrame as IntoDataFrame
-from narwhals.typing import IntoDataFrameT as IntoDataFrameT
-from narwhals.typing import IntoExpr as IntoExpr
+from narwhals.stable.v1.dtypes import DType as DType
+from narwhals.stable.v1.typing import DataFrameT as DataFrameT
+from narwhals.stable.v1.typing import IntoDataFrame as IntoDataFrame
+from narwhals.stable.v1.typing import IntoDataFrameT as IntoDataFrameT
+from narwhals.stable.v1.typing import IntoExpr as IntoExpr
 
 from ..._typing_extensions import Annotated, NotRequired, Required, TypedDict
 from ...types import Jsonifiable, JsonifiableDict, ListOrTuple
diff --git a/tests/playwright/shiny/components/data_frame/data_view_info/app.py b/tests/playwright/shiny/components/data_frame/data_view_info/app.py
index 9edce24d..0d1a08d3 100644
--- a/tests/playwright/shiny/components/data_frame/data_view_info/app.py
+++ b/tests/playwright/shiny/components/data_frame/data_view_info/app.py
@@ -5,7 +5,7 @@ from __future__ import annotations
 # pyright: reportArgumentType = false
 # pyright: reportUnknownMemberType = false
 import polars as pl
-from narwhals.typing import IntoDataFrame
+from narwhals.stable.v1.typing import IntoDataFrame
 from palmerpenguins import load_penguins_raw
 
 from shiny import App, Inputs, Outputs, Session, module, render, ui
diff --git a/tests/playwright/shiny/components/data_frame/df_methods/app.py b/tests/playwright/shiny/components/data_frame/df_methods/app.py
index 3819d066..fb55d944 100644
--- a/tests/playwright/shiny/components/data_frame/df_methods/app.py
+++ b/tests/playwright/shiny/components/data_frame/df_methods/app.py
@@ -1,7 +1,7 @@
 import pandas as pd
 import polars as pl
 import seaborn as sns
-from narwhals.typing import IntoDataFrame
+from narwhals.stable.v1.typing import IntoDataFrame
 
 from shiny import App, Inputs, Outputs, Session, module, reactive, render, ui
 
diff --git a/tests/playwright/shiny/components/data_frame/row_selection/app.py b/tests/playwright/shiny/components/data_frame/row_selection/app.py
index 1d809fd5..b4c9fe7d 100644
--- a/tests/playwright/shiny/components/data_frame/row_selection/app.py
+++ b/tests/playwright/shiny/components/data_frame/row_selection/app.py
@@ -2,7 +2,7 @@ import pkgutil
 
 import palmerpenguins  # pyright: ignore[reportMissingTypeStubs]
 import polars as pl
-from narwhals.typing import IntoDataFrame
+from narwhals.stable.v1.typing import IntoDataFrame
 
 from shiny import App, Inputs, Outputs, Session, module, reactive, render, ui
 
diff --git a/tests/playwright/shiny/components/data_frame/styles/app.py b/tests/playwright/shiny/components/data_frame/styles/app.py
index cb2de7e2..ebfa9032 100644
--- a/tests/playwright/shiny/components/data_frame/styles/app.py
+++ b/tests/playwright/shiny/components/data_frame/styles/app.py
@@ -5,7 +5,7 @@ import pkgutil
 # pyright: reportMissingTypeStubs = false
 import palmerpenguins
 import polars as pl
-from narwhals.typing import IntoDataFrame
+from narwhals.stable.v1.typing import IntoDataFrame
 
 from shiny import App, Inputs, Outputs, Session, module, render, ui
 
diff --git a/tests/playwright/shiny/components/data_frame/validate_column_labels/app.py b/tests/playwright/shiny/components/data_frame/validate_column_labels/app.py
index 2ee08a11..99c321ee 100644
--- a/tests/playwright/shiny/components/data_frame/validate_column_labels/app.py
+++ b/tests/playwright/shiny/components/data_frame/validate_column_labels/app.py
@@ -4,7 +4,7 @@ import pkgutil
 
 import palmerpenguins  # pyright: ignore[reportMissingTypeStubs]
 import polars as pl
-from narwhals.typing import IntoDataFrame
+from narwhals.stable.v1.typing import IntoDataFrame
 
 from shiny import Inputs, Outputs, Session
 from shiny.express import module, render, ui
diff --git a/tests/pytest/test_render_data_frame_tbl_data.py b/tests/pytest/test_render_data_frame_tbl_data.py
index 0bb3676e..6b5b777f 100644
--- a/tests/pytest/test_render_data_frame_tbl_data.py
+++ b/tests/pytest/test_render_data_frame_tbl_data.py
@@ -341,7 +341,7 @@ def test_subset_frame_cols_single(small_df_f: IntoDataFrame):
 def test_dtype_coverage():
     from pathlib import Path
 
-    from narwhals import dtypes as nw_dtypes
+    from narwhals.stable.v1 import dtypes as nw_dtypes
 
     # Copy from https://github.com/narwhals-dev/narwhals/blob/2c9e2e7a308ebb30c6f672e27c1da2086ebbecbc/utils/check_api_reference.py#L144-L146
     dtype_names = [

and then both make check-tests and make ci-check-mypy-can-run passed

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🔧 Optimization
  • 📝 Documentation
  • ✅ Test
  • 🐳 Other

Related issues

  • Related issue #
  • Closes #

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below.

@github-actions github-actions bot added the enhancement New feature or request label Oct 4, 2024
@MarcoGorelli MarcoGorelli marked this pull request as ready for review October 4, 2024 13:15
@MarcoGorelli MarcoGorelli merged commit f4ec002 into narwhals-dev:main Oct 4, 2024
24 checks passed
akmalsoliev pushed a commit to akmalsoliev/narwhals that referenced this pull request Oct 15, 2024
* make typing available under narwhals.stable.v1

* coverage

* py-shiny compat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant