diff --git a/narwhals/__init__.py b/narwhals/__init__.py index 21964da15..aeba3ef5e 100644 --- a/narwhals/__init__.py +++ b/narwhals/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from narwhals import dependencies from narwhals import selectors from narwhals import stable diff --git a/narwhals/stable/__init__.py b/narwhals/stable/__init__.py index 572034fe7..60bc872a5 100644 --- a/narwhals/stable/__init__.py +++ b/narwhals/stable/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from narwhals.stable import v1 __all__ = ["v1"] diff --git a/narwhals/stable/v1/_dtypes.py b/narwhals/stable/v1/_dtypes.py index 84c9adc90..459441d66 100644 --- a/narwhals/stable/v1/_dtypes.py +++ b/narwhals/stable/v1/_dtypes.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from narwhals.dtypes import Array from narwhals.dtypes import Boolean from narwhals.dtypes import Categorical diff --git a/narwhals/stable/v1/dtypes.py b/narwhals/stable/v1/dtypes.py index 21bd1c5ed..37c3af0e8 100644 --- a/narwhals/stable/v1/dtypes.py +++ b/narwhals/stable/v1/dtypes.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from narwhals.stable.v1._dtypes import Array from narwhals.stable.v1._dtypes import Boolean from narwhals.stable.v1._dtypes import Categorical diff --git a/noxfile.py b/noxfile.py index 1dc37b29d..1fb820c65 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import nox -from nox.sessions import Session + +if TYPE_CHECKING: + from nox.sessions import Session nox.options.default_venv_backend = "uv" nox.options.reuse_venv = True diff --git a/pyproject.toml b/pyproject.toml index 3cbeff8f5..d525fb677 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,6 +94,7 @@ convention = "google" [tool.ruff.lint.isort] force-single-line = true +required-imports = ["from __future__ import annotations"] [tool.ruff.format] docstring-code-format = true diff --git a/tests/conftest.py b/tests/conftest.py index 85c296daf..18ef366cc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,7 @@ +from __future__ import annotations + import contextlib +from typing import TYPE_CHECKING from typing import Any from typing import Callable @@ -10,10 +13,12 @@ from narwhals.dependencies import get_cudf from narwhals.dependencies import get_dask_dataframe from narwhals.dependencies import get_modin -from narwhals.typing import IntoDataFrame -from narwhals.typing import IntoFrame from narwhals.utils import parse_version -from tests.utils import Constructor + +if TYPE_CHECKING: + from narwhals.typing import IntoDataFrame + from narwhals.typing import IntoFrame + from tests.utils import Constructor with contextlib.suppress(ImportError): import modin.pandas # noqa: F401 @@ -108,7 +113,9 @@ def pyarrow_table_constructor(obj: Any) -> IntoDataFrame: @pytest.fixture(params=eager_constructors) -def constructor_eager(request: pytest.FixtureRequest) -> Callable[[Any], IntoDataFrame]: +def constructor_eager( + request: pytest.FixtureRequest, +) -> Callable[[Any], IntoDataFrame]: return request.param # type: ignore[no-any-return] diff --git a/tests/dependencies/is_pandas_dataframe_test.py b/tests/dependencies/is_pandas_dataframe_test.py index a8ffaa739..96b874952 100644 --- a/tests/dependencies/is_pandas_dataframe_test.py +++ b/tests/dependencies/is_pandas_dataframe_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import polars as pl diff --git a/tests/expr_and_series/abs_test.py b/tests/expr_and_series/abs_test.py index c883d7161..c324a9cfd 100644 --- a/tests/expr_and_series/abs_test.py +++ b/tests/expr_and_series/abs_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/all_horizontal_test.py b/tests/expr_and_series/all_horizontal_test.py index a5ba44600..beeaecca7 100644 --- a/tests/expr_and_series/all_horizontal_test.py +++ b/tests/expr_and_series/all_horizontal_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import polars as pl @@ -66,7 +68,7 @@ def test_allh_nth(constructor: Constructor, request: pytest.FixtureRequest) -> N compare_dicts(result, expected) -def test_horizontal_expressions_emtpy(constructor: Constructor) -> None: +def test_horizontal_expressions_empty(constructor: Constructor) -> None: data = { "a": [False, False, True], "b": [False, True, True], diff --git a/tests/expr_and_series/any_all_test.py b/tests/expr_and_series/any_all_test.py index 73294c708..2406cdcff 100644 --- a/tests/expr_and_series/any_all_test.py +++ b/tests/expr_and_series/any_all_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/any_horizontal_test.py b/tests/expr_and_series/any_horizontal_test.py index cd360bf66..d98cd34d6 100644 --- a/tests/expr_and_series/any_horizontal_test.py +++ b/tests/expr_and_series/any_horizontal_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pytest diff --git a/tests/expr_and_series/arg_true_test.py b/tests/expr_and_series/arg_true_test.py index 1f71e2c42..ba6b5d68d 100644 --- a/tests/expr_and_series/arg_true_test.py +++ b/tests/expr_and_series/arg_true_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/binary_test.py b/tests/expr_and_series/binary_test.py index 1ce76d9d2..6826cda37 100644 --- a/tests/expr_and_series/binary_test.py +++ b/tests/expr_and_series/binary_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/expr_and_series/clip_test.py b/tests/expr_and_series/clip_test.py index 2406f289f..14496fc49 100644 --- a/tests/expr_and_series/clip_test.py +++ b/tests/expr_and_series/clip_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/count_test.py b/tests/expr_and_series/count_test.py index ec90e1fc1..603a6daf8 100644 --- a/tests/expr_and_series/count_test.py +++ b/tests/expr_and_series/count_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/cum_sum_test.py b/tests/expr_and_series/cum_sum_test.py index a490b890e..e94bd168c 100644 --- a/tests/expr_and_series/cum_sum_test.py +++ b/tests/expr_and_series/cum_sum_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/diff_test.py b/tests/expr_and_series/diff_test.py index ada3147ed..c62b68d40 100644 --- a/tests/expr_and_series/diff_test.py +++ b/tests/expr_and_series/diff_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pyarrow as pa import pytest diff --git a/tests/expr_and_series/double_selected_test.py b/tests/expr_and_series/double_selected_test.py index 88826fb40..001e1f848 100644 --- a/tests/expr_and_series/double_selected_test.py +++ b/tests/expr_and_series/double_selected_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/expr_and_series/double_test.py b/tests/expr_and_series/double_test.py index 8f19e0202..66af086db 100644 --- a/tests/expr_and_series/double_test.py +++ b/tests/expr_and_series/double_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/expr_and_series/fill_null_test.py b/tests/expr_and_series/fill_null_test.py index 9fa7afaf9..a6315ae59 100644 --- a/tests/expr_and_series/fill_null_test.py +++ b/tests/expr_and_series/fill_null_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/filter_test.py b/tests/expr_and_series/filter_test.py index dff987ecb..afddff244 100644 --- a/tests/expr_and_series/filter_test.py +++ b/tests/expr_and_series/filter_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/gather_every_test.py b/tests/expr_and_series/gather_every_test.py index e6f68be1d..2a2ce154b 100644 --- a/tests/expr_and_series/gather_every_test.py +++ b/tests/expr_and_series/gather_every_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/is_duplicated_test.py b/tests/expr_and_series/is_duplicated_test.py index d0c5ae3dc..d5c934a04 100644 --- a/tests/expr_and_series/is_duplicated_test.py +++ b/tests/expr_and_series/is_duplicated_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/is_first_distinct_test.py b/tests/expr_and_series/is_first_distinct_test.py index 4f22d02f9..c4ad865e3 100644 --- a/tests/expr_and_series/is_first_distinct_test.py +++ b/tests/expr_and_series/is_first_distinct_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/is_in_test.py b/tests/expr_and_series/is_in_test.py index 29d3cf56b..6a568053a 100644 --- a/tests/expr_and_series/is_in_test.py +++ b/tests/expr_and_series/is_in_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/is_last_distinct_test.py b/tests/expr_and_series/is_last_distinct_test.py index e63c161b3..efad08dcb 100644 --- a/tests/expr_and_series/is_last_distinct_test.py +++ b/tests/expr_and_series/is_last_distinct_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/is_null_test.py b/tests/expr_and_series/is_null_test.py index a3d5d2bae..edc0e8953 100644 --- a/tests/expr_and_series/is_null_test.py +++ b/tests/expr_and_series/is_null_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/is_unique_test.py b/tests/expr_and_series/is_unique_test.py index 8d46db92d..39d6fc071 100644 --- a/tests/expr_and_series/is_unique_test.py +++ b/tests/expr_and_series/is_unique_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/len_test.py b/tests/expr_and_series/len_test.py index 535c7dc92..8d582ce1c 100644 --- a/tests/expr_and_series/len_test.py +++ b/tests/expr_and_series/len_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/max_horizontal_test.py b/tests/expr_and_series/max_horizontal_test.py index 711ce4e0d..8da95e317 100644 --- a/tests/expr_and_series/max_horizontal_test.py +++ b/tests/expr_and_series/max_horizontal_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pytest diff --git a/tests/expr_and_series/mean_horizontal_test.py b/tests/expr_and_series/mean_horizontal_test.py index ce9ac8fe0..eb78a868e 100644 --- a/tests/expr_and_series/mean_horizontal_test.py +++ b/tests/expr_and_series/mean_horizontal_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pytest diff --git a/tests/expr_and_series/min_horizontal_test.py b/tests/expr_and_series/min_horizontal_test.py index ca34d440d..eaad0528f 100644 --- a/tests/expr_and_series/min_horizontal_test.py +++ b/tests/expr_and_series/min_horizontal_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pytest @@ -7,19 +9,19 @@ from tests.utils import compare_dicts data = {"a": [1, 3, None, None], "b": [4, None, 6, None], "z": [3, 1, None, None]} -expcted_values = [1, 1, 6, float("nan")] +expected_values = [1, 1, 6, float("nan")] @pytest.mark.parametrize("col_expr", [nw.col("a"), "a"]) def test_minh(constructor: Constructor, col_expr: Any) -> None: df = nw.from_native(constructor(data)) result = df.select(horizontal_min=nw.min_horizontal(col_expr, nw.col("b"), "z")) - expected = {"horizontal_min": expcted_values} + expected = {"horizontal_min": expected_values} compare_dicts(result, expected) def test_minh_all(constructor: Constructor) -> None: df = nw.from_native(constructor(data)) result = df.select(nw.min_horizontal(nw.all()), c=nw.min_horizontal(nw.all())) - expected = {"a": expcted_values, "c": expcted_values} + expected = {"a": expected_values, "c": expected_values} compare_dicts(result, expected) diff --git a/tests/expr_and_series/mode_test.py b/tests/expr_and_series/mode_test.py index 820e05ad8..2e752ebb9 100644 --- a/tests/expr_and_series/mode_test.py +++ b/tests/expr_and_series/mode_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import polars as pl import pytest diff --git a/tests/expr_and_series/n_unique_test.py b/tests/expr_and_series/n_unique_test.py index c4199eec1..d54e815cc 100644 --- a/tests/expr_and_series/n_unique_test.py +++ b/tests/expr_and_series/n_unique_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/null_count_test.py b/tests/expr_and_series/null_count_test.py index 93d467cb3..28aa66f38 100644 --- a/tests/expr_and_series/null_count_test.py +++ b/tests/expr_and_series/null_count_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/over_test.py b/tests/expr_and_series/over_test.py index 2abc9a699..4f89c29e5 100644 --- a/tests/expr_and_series/over_test.py +++ b/tests/expr_and_series/over_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from contextlib import nullcontext as does_not_raise import pytest diff --git a/tests/expr_and_series/pipe_test.py b/tests/expr_and_series/pipe_test.py index 84b6006d7..812422f7f 100644 --- a/tests/expr_and_series/pipe_test.py +++ b/tests/expr_and_series/pipe_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/sample_test.py b/tests/expr_and_series/sample_test.py index eb6d853ec..c228ca0bd 100644 --- a/tests/expr_and_series/sample_test.py +++ b/tests/expr_and_series/sample_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/shift_test.py b/tests/expr_and_series/shift_test.py index a665ff768..388b8e6ab 100644 --- a/tests/expr_and_series/shift_test.py +++ b/tests/expr_and_series/shift_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pyarrow as pa import narwhals.stable.v1 as nw diff --git a/tests/expr_and_series/sort_test.py b/tests/expr_and_series/sort_test.py index 2ea8cd145..3721c2599 100644 --- a/tests/expr_and_series/sort_test.py +++ b/tests/expr_and_series/sort_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pytest diff --git a/tests/expr_and_series/std_test.py b/tests/expr_and_series/std_test.py index 09779c109..9ed57c571 100644 --- a/tests/expr_and_series/std_test.py +++ b/tests/expr_and_series/std_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/str/contains_test.py b/tests/expr_and_series/str/contains_test.py index 139b71eb8..2c2e0cb9f 100644 --- a/tests/expr_and_series/str/contains_test.py +++ b/tests/expr_and_series/str/contains_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import polars as pl import pytest diff --git a/tests/expr_and_series/str/head_test.py b/tests/expr_and_series/str/head_test.py index 8da64553e..00406e9d4 100644 --- a/tests/expr_and_series/str/head_test.py +++ b/tests/expr_and_series/str/head_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/str/len_chars_test.py b/tests/expr_and_series/str/len_chars_test.py index 80a791c61..f95efd1a2 100644 --- a/tests/expr_and_series/str/len_chars_test.py +++ b/tests/expr_and_series/str/len_chars_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/str/tail_test.py b/tests/expr_and_series/str/tail_test.py index 260ab745c..aa0821075 100644 --- a/tests/expr_and_series/str/tail_test.py +++ b/tests/expr_and_series/str/tail_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager diff --git a/tests/expr_and_series/sum_horizontal_test.py b/tests/expr_and_series/sum_horizontal_test.py index e9e1e4a3c..91d0d3bb9 100644 --- a/tests/expr_and_series/sum_horizontal_test.py +++ b/tests/expr_and_series/sum_horizontal_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pytest diff --git a/tests/expr_and_series/tail_test.py b/tests/expr_and_series/tail_test.py index 73acb6848..8a7ae8f5b 100644 --- a/tests/expr_and_series/tail_test.py +++ b/tests/expr_and_series/tail_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals as nw diff --git a/tests/expr_and_series/unary_test.py b/tests/expr_and_series/unary_test.py index c1e1d007b..71a00f8f3 100644 --- a/tests/expr_and_series/unary_test.py +++ b/tests/expr_and_series/unary_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import ConstructorEager @@ -6,17 +8,12 @@ def test_unary(constructor: Constructor) -> None: data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]} - result = ( - nw.from_native(constructor(data)) - .with_columns( - a_mean=nw.col("a").mean(), - a_sum=nw.col("a").sum(), - b_nunique=nw.col("b").n_unique(), - z_min=nw.col("z").min(), - z_max=nw.col("z").max(), - ) - .unique(["a_mean", "a_sum", "b_nunique", "z_min", "z_max"]) - .select(["a_mean", "a_sum", "b_nunique", "z_min", "z_max"]) + result = nw.from_native(constructor(data)).select( + a_mean=nw.col("a").mean(), + a_sum=nw.col("a").sum(), + b_nunique=nw.col("b").n_unique(), + z_min=nw.col("z").min(), + z_max=nw.col("z").max(), ) expected = { "a_mean": [2], diff --git a/tests/expr_and_series/unique_test.py b/tests/expr_and_series/unique_test.py index 5048d3250..db0478e80 100644 --- a/tests/expr_and_series/unique_test.py +++ b/tests/expr_and_series/unique_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/frame/add_test.py b/tests/frame/add_test.py index c95fbae97..69133c2e8 100644 --- a/tests/frame/add_test.py +++ b/tests/frame/add_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/frame/array_dunder_test.py b/tests/frame/array_dunder_test.py index ad3085f56..90db2b621 100644 --- a/tests/frame/array_dunder_test.py +++ b/tests/frame/array_dunder_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np import pandas as pd import polars as pl diff --git a/tests/frame/arrow_c_stream_test.py b/tests/frame/arrow_c_stream_test.py index cb856adf9..66525f1b9 100644 --- a/tests/frame/arrow_c_stream_test.py +++ b/tests/frame/arrow_c_stream_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import polars as pl import pyarrow as pa import pyarrow.compute as pc diff --git a/tests/frame/clone_test.py b/tests/frame/clone_test.py index e94183e2e..c115d0899 100644 --- a/tests/frame/clone_test.py +++ b/tests/frame/clone_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/frame/columns_test.py b/tests/frame/columns_test.py index 90a9c922d..3a18fb591 100644 --- a/tests/frame/columns_test.py +++ b/tests/frame/columns_test.py @@ -1,7 +1,13 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import pytest import narwhals.stable.v1 as nw -from tests.utils import Constructor + +if TYPE_CHECKING: + from tests.utils import Constructor @pytest.mark.filterwarnings("ignore:Determining|Resolving.*") diff --git a/tests/frame/concat_test.py b/tests/frame/concat_test.py index 926f3f988..ebf4bcb05 100644 --- a/tests/frame/concat_test.py +++ b/tests/frame/concat_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/frame/double_test.py b/tests/frame/double_test.py index 6840145ec..1c46bf3f7 100644 --- a/tests/frame/double_test.py +++ b/tests/frame/double_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/frame/filter_test.py b/tests/frame/filter_test.py index 9c9b1b6fd..3f10fba8a 100644 --- a/tests/frame/filter_test.py +++ b/tests/frame/filter_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from contextlib import nullcontext as does_not_raise import pytest diff --git a/tests/frame/gather_every_test.py b/tests/frame/gather_every_test.py index 40e18a30b..347132c14 100644 --- a/tests/frame/gather_every_test.py +++ b/tests/frame/gather_every_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/frame/get_column_test.py b/tests/frame/get_column_test.py index ff4ebc506..b0a2a7ca5 100644 --- a/tests/frame/get_column_test.py +++ b/tests/frame/get_column_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import pytest diff --git a/tests/frame/interchange_native_namespace_test.py b/tests/frame/interchange_native_namespace_test.py index 8a67d07b8..084f6ea05 100644 --- a/tests/frame/interchange_native_namespace_test.py +++ b/tests/frame/interchange_native_namespace_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import duckdb import polars as pl import pytest diff --git a/tests/frame/interchange_schema_test.py b/tests/frame/interchange_schema_test.py index afec06831..33f2e0044 100644 --- a/tests/frame/interchange_schema_test.py +++ b/tests/frame/interchange_schema_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from datetime import date from datetime import datetime from datetime import timedelta diff --git a/tests/frame/interchange_to_arrow_test.py b/tests/frame/interchange_to_arrow_test.py index 7308607ea..d1ddd2a53 100644 --- a/tests/frame/interchange_to_arrow_test.py +++ b/tests/frame/interchange_to_arrow_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import duckdb import polars as pl import pyarrow as pa diff --git a/tests/frame/interchange_to_pandas_test.py b/tests/frame/interchange_to_pandas_test.py index f56575fa3..3cb722b1c 100644 --- a/tests/frame/interchange_to_pandas_test.py +++ b/tests/frame/interchange_to_pandas_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import duckdb import pandas as pd import pytest diff --git a/tests/frame/invalid_test.py b/tests/frame/invalid_test.py index 2fdf53949..834e192b7 100644 --- a/tests/frame/invalid_test.py +++ b/tests/frame/invalid_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np import pandas as pd import polars as pl diff --git a/tests/frame/lazy_test.py b/tests/frame/lazy_test.py index 8f1566e69..df27a4cc9 100644 --- a/tests/frame/lazy_test.py +++ b/tests/frame/lazy_test.py @@ -1,6 +1,12 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw import narwhals.stable.v1 as nw_v1 -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager def test_lazy(constructor_eager: ConstructorEager) -> None: diff --git a/tests/frame/len_test.py b/tests/frame/len_test.py index cd082ef2e..b22f0c67d 100644 --- a/tests/frame/len_test.py +++ b/tests/frame/len_test.py @@ -1,6 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals.stable.v1 as nw -from tests.utils import ConstructorEager +if TYPE_CHECKING: + from tests.utils import ConstructorEager data = { "a": [1.0, 2.0, None, 4.0], "b": [None, 3.0, None, 5.0], diff --git a/tests/frame/pipe_test.py b/tests/frame/pipe_test.py index b7b57e0a1..506d4a317 100644 --- a/tests/frame/pipe_test.py +++ b/tests/frame/pipe_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/frame/reindex_test.py b/tests/frame/reindex_test.py index e21b31a8e..431e7b002 100644 --- a/tests/frame/reindex_test.py +++ b/tests/frame/reindex_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any import pandas as pd diff --git a/tests/frame/rename_test.py b/tests/frame/rename_test.py index 79cf3f243..d51e86f83 100644 --- a/tests/frame/rename_test.py +++ b/tests/frame/rename_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/frame/row_test.py b/tests/frame/row_test.py index d977a81f1..82af94146 100644 --- a/tests/frame/row_test.py +++ b/tests/frame/row_test.py @@ -1,9 +1,14 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING from typing import Any import pytest import narwhals.stable.v1 as nw -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager def test_row_column(request: Any, constructor_eager: ConstructorEager) -> None: diff --git a/tests/frame/rows_test.py b/tests/frame/rows_test.py index 60e18658c..7e5c1ecef 100644 --- a/tests/frame/rows_test.py +++ b/tests/frame/rows_test.py @@ -4,44 +4,15 @@ from typing import Any import pandas as pd -import polars as pl -import pyarrow as pa import pytest import narwhals.stable.v1 as nw -from narwhals.utils import parse_version if TYPE_CHECKING: from tests.utils import ConstructorEager -df_pandas = pd.DataFrame({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) -df_pa = pa.table({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) -if parse_version(pd.__version__) >= parse_version("1.5.0"): - df_pandas_pyarrow = pd.DataFrame( - {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]} - ).astype( - { - "a": "Int64[pyarrow]", - "b": "Int64[pyarrow]", - "z": "Float64[pyarrow]", - } - ) - df_pandas_nullable = pd.DataFrame( - {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]} - ).astype( - { - "a": "Int64", - "b": "Int64", - "z": "Float64", - } - ) -else: # pragma: no cover - df_pandas_pyarrow = df_pandas - df_pandas_nullable = df_pandas -df_polars = pl.DataFrame({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) - -df_pandas_na = pd.DataFrame({"a": [None, 3, 2], "b": [4, 4, 6], "z": [7.0, None, 9]}) -df_polars_na = pl.DataFrame({"a": [None, 3, 2], "b": [4, 4, 6], "z": [7.0, None, 9]}) +data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]} +data_na = {"a": [None, 3, 2], "b": [4, 4, 6], "z": [7.0, None, 9]} @pytest.mark.parametrize( @@ -73,8 +44,8 @@ def test_iter_rows( assert result == expected -@pytest.mark.parametrize( - "df_raw", [df_pandas, df_pandas_nullable, df_pandas_pyarrow, df_polars, df_pa] +@pytest.mark.filterwarnings( + "ignore:.*all arguments of to_dict except for the argument:FutureWarning" ) @pytest.mark.parametrize( ("named", "expected"), @@ -91,19 +62,18 @@ def test_iter_rows( ], ) def test_rows( - df_raw: Any, + constructor_eager: ConstructorEager, named: bool, # noqa: FBT001 expected: list[tuple[Any, ...]] | list[dict[str, Any]], ) -> None: - df = nw.from_native(df_raw, eager_only=True) + df = nw.from_native(constructor_eager(data), eager_only=True) result = df.rows(named=named) assert result == expected -@pytest.mark.parametrize("df_raw", [df_pandas_na, df_polars_na]) -def test_rows_with_nulls_unnamed(df_raw: Any) -> None: +def test_rows_with_nulls_unnamed(constructor_eager: ConstructorEager) -> None: # GIVEN - df = nw.from_native(df_raw, eager_only=True) + df = nw.from_native(constructor_eager(data_na), eager_only=True) # WHEN result = list(df.iter_rows(named=False)) @@ -119,10 +89,9 @@ def test_rows_with_nulls_unnamed(df_raw: Any) -> None: assert value_in_result == value -@pytest.mark.parametrize("df_raw", [df_pandas_na, df_polars_na]) -def test_rows_with_nulls_named(df_raw: Any) -> None: +def test_rows_with_nulls_named(constructor_eager: ConstructorEager) -> None: # GIVEN - df = nw.from_native(df_raw, eager_only=True) + df = nw.from_native(constructor_eager(data_na), eager_only=True) # WHEN result = list(df.iter_rows(named=True)) diff --git a/tests/frame/sample_test.py b/tests/frame/sample_test.py index 88d5969c3..ff3591fdd 100644 --- a/tests/frame/sample_test.py +++ b/tests/frame/sample_test.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals.stable.v1 as nw -from tests.utils import Constructor + +if TYPE_CHECKING: + from tests.utils import Constructor def test_sample_n(constructor_eager: Constructor) -> None: diff --git a/tests/frame/schema_test.py b/tests/frame/schema_test.py index 97c3722a7..65da7bf00 100644 --- a/tests/frame/schema_test.py +++ b/tests/frame/schema_test.py @@ -1,7 +1,10 @@ +from __future__ import annotations + from datetime import date from datetime import datetime from datetime import timedelta from datetime import timezone +from typing import TYPE_CHECKING from typing import Any import duckdb @@ -11,8 +14,11 @@ import narwhals.stable.v1 as nw from narwhals.utils import parse_version -from tests.utils import Constructor -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import Constructor + from tests.utils import ConstructorEager + data = { "a": [datetime(2020, 1, 1)], diff --git a/tests/frame/select_test.py b/tests/frame/select_test.py index 8c01be407..df7821a5b 100644 --- a/tests/frame/select_test.py +++ b/tests/frame/select_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import pytest diff --git a/tests/frame/shape_test.py b/tests/frame/shape_test.py index 6930214f7..6cbee058d 100644 --- a/tests/frame/shape_test.py +++ b/tests/frame/shape_test.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals.stable.v1 as nw -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager def test_shape(constructor_eager: ConstructorEager) -> None: diff --git a/tests/frame/to_dict_test.py b/tests/frame/to_dict_test.py index b76003bd1..537b68f31 100644 --- a/tests/frame/to_dict_test.py +++ b/tests/frame/to_dict_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/frame/to_native_test.py b/tests/frame/to_native_test.py index c6de99a17..fb90caf10 100644 --- a/tests/frame/to_native_test.py +++ b/tests/frame/to_native_test.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals.stable.v1 as nw -from tests.utils import Constructor + +if TYPE_CHECKING: + from tests.utils import Constructor def test_to_native(constructor: Constructor) -> None: diff --git a/tests/frame/with_columns_sequence_test.py b/tests/frame/with_columns_sequence_test.py index 49db7820b..5249f0106 100644 --- a/tests/frame/with_columns_sequence_test.py +++ b/tests/frame/with_columns_sequence_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np import pytest diff --git a/tests/frame/with_columns_test.py b/tests/frame/with_columns_test.py index 8c949cc53..722df5c01 100644 --- a/tests/frame/with_columns_test.py +++ b/tests/frame/with_columns_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np import pandas as pd import pyarrow as pa diff --git a/tests/frame/with_row_index_test.py b/tests/frame/with_row_index_test.py index 8f802de0a..a4307acc3 100644 --- a/tests/frame/with_row_index_test.py +++ b/tests/frame/with_row_index_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/from_dict_test.py b/tests/from_dict_test.py index 4583b03e5..9797713d9 100644 --- a/tests/from_dict_test.py +++ b/tests/from_dict_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals as nw diff --git a/tests/from_pycapsule_test.py b/tests/from_pycapsule_test.py index 7ab8f1fe8..496138dd2 100644 --- a/tests/from_pycapsule_test.py +++ b/tests/from_pycapsule_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys import pandas as pd diff --git a/tests/new_series_test.py b/tests/new_series_test.py index 37e5d2633..f5dda284d 100644 --- a/tests/new_series_test.py +++ b/tests/new_series_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import pytest diff --git a/tests/no_imports_test.py b/tests/no_imports_test.py index b30545380..a6fe26e31 100644 --- a/tests/no_imports_test.py +++ b/tests/no_imports_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys import pandas as pd diff --git a/tests/series_only/alias_rename_test.py b/tests/series_only/alias_rename_test.py index 4fa8a9993..021992735 100644 --- a/tests/series_only/alias_rename_test.py +++ b/tests/series_only/alias_rename_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals as nw from tests.utils import Constructor from tests.utils import compare_dicts diff --git a/tests/series_only/array_dunder_test.py b/tests/series_only/array_dunder_test.py index 0d95e2db3..3c30ef894 100644 --- a/tests/series_only/array_dunder_test.py +++ b/tests/series_only/array_dunder_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np import pandas as pd import pyarrow as pa diff --git a/tests/series_only/arrow_c_stream_test.py b/tests/series_only/arrow_c_stream_test.py index 9d2ebc8d0..3417bb9a5 100644 --- a/tests/series_only/arrow_c_stream_test.py +++ b/tests/series_only/arrow_c_stream_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import polars as pl import pyarrow as pa import pyarrow.compute as pc diff --git a/tests/series_only/cast_test.py b/tests/series_only/cast_test.py index 672cbebc2..55752149b 100644 --- a/tests/series_only/cast_test.py +++ b/tests/series_only/cast_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from datetime import date from datetime import datetime diff --git a/tests/series_only/is_empty_test.py b/tests/series_only/is_empty_test.py index 390fa7f4f..bd3aa61ed 100644 --- a/tests/series_only/is_empty_test.py +++ b/tests/series_only/is_empty_test.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals.stable.v1 as nw -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager def test_is_empty(constructor_eager: ConstructorEager) -> None: diff --git a/tests/series_only/is_ordered_categorical_test.py b/tests/series_only/is_ordered_categorical_test.py index 10251e362..58aa9616f 100644 --- a/tests/series_only/is_ordered_categorical_test.py +++ b/tests/series_only/is_ordered_categorical_test.py @@ -1,3 +1,7 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import pandas as pd import polars as pl import pyarrow as pa @@ -5,7 +9,9 @@ import narwhals.stable.v1 as nw from narwhals.utils import parse_version -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager def test_is_ordered_categorical() -> None: diff --git a/tests/series_only/shape_test.py b/tests/series_only/shape_test.py index d3e276bb2..1ab88eca3 100644 --- a/tests/series_only/shape_test.py +++ b/tests/series_only/shape_test.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals.stable.v1 as nw -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager def test_shape(constructor_eager: ConstructorEager) -> None: diff --git a/tests/series_only/slice_test.py b/tests/series_only/slice_test.py index eba24fdbd..0744c1b77 100644 --- a/tests/series_only/slice_test.py +++ b/tests/series_only/slice_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import ConstructorEager from tests.utils import compare_dicts diff --git a/tests/series_only/to_dummy_test.py b/tests/series_only/to_dummy_test.py index 938b8d04e..52b51242e 100644 --- a/tests/series_only/to_dummy_test.py +++ b/tests/series_only/to_dummy_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/series_only/to_frame_test.py b/tests/series_only/to_frame_test.py index 065da1414..77be9a4be 100644 --- a/tests/series_only/to_frame_test.py +++ b/tests/series_only/to_frame_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import narwhals.stable.v1 as nw from tests.utils import ConstructorEager from tests.utils import compare_dicts diff --git a/tests/series_only/to_list_test.py b/tests/series_only/to_list_test.py index 0f91b9879..ebea07cff 100644 --- a/tests/series_only/to_list_test.py +++ b/tests/series_only/to_list_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import narwhals.stable.v1 as nw diff --git a/tests/stable_api_test.py b/tests/stable_api_test.py index 7a67f5723..a076b0218 100644 --- a/tests/stable_api_test.py +++ b/tests/stable_api_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from datetime import datetime from datetime import timedelta from typing import Any diff --git a/tests/system_info_test.py b/tests/system_info_test.py index 30bb0c400..75a2b190f 100644 --- a/tests/system_info_test.py +++ b/tests/system_info_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import warnings from typing import Any diff --git a/tests/translate/from_native_test.py b/tests/translate/from_native_test.py index 8ac33b620..2d5ecd642 100644 --- a/tests/translate/from_native_test.py +++ b/tests/translate/from_native_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from contextlib import nullcontext as does_not_raise from typing import Any diff --git a/tests/translate/get_native_namespace_test.py b/tests/translate/get_native_namespace_test.py index 60b80a1d9..f02c4c8da 100644 --- a/tests/translate/get_native_namespace_test.py +++ b/tests/translate/get_native_namespace_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import polars as pl import pyarrow as pa diff --git a/tests/translate/to_native_test.py b/tests/translate/to_native_test.py index 90ec11ab1..3d116a459 100644 --- a/tests/translate/to_native_test.py +++ b/tests/translate/to_native_test.py @@ -1,10 +1,15 @@ +from __future__ import annotations + from contextlib import nullcontext as does_not_raise +from typing import TYPE_CHECKING from typing import Any import pytest import narwhals.stable.v1 as nw -from tests.utils import ConstructorEager + +if TYPE_CHECKING: + from tests.utils import ConstructorEager @pytest.mark.parametrize( diff --git a/tests/utils_test.py b/tests/utils_test.py index cea458bc9..30805b15d 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd import polars as pl import pytest diff --git a/tpch/__init__.py b/tpch/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tpch/execute/__init__.py b/tpch/execute/__init__.py index e0c448649..ecbf1db53 100644 --- a/tpch/execute/__init__.py +++ b/tpch/execute/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path import dask.dataframe as dd diff --git a/tpch/execute/q1.py b/tpch/execute/q1.py index 9889c3af0..d0ebce584 100644 --- a/tpch/execute/q1.py +++ b/tpch/execute/q1.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q1 from . import IO_FUNCS diff --git a/tpch/execute/q10.py b/tpch/execute/q10.py index 124bf0f7d..1f610932c 100644 --- a/tpch/execute/q10.py +++ b/tpch/execute/q10.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q10 from . import IO_FUNCS diff --git a/tpch/execute/q11.py b/tpch/execute/q11.py index 8c0a2e649..0dd8a243c 100644 --- a/tpch/execute/q11.py +++ b/tpch/execute/q11.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q11 from . import IO_FUNCS diff --git a/tpch/execute/q12.py b/tpch/execute/q12.py index 3c3a70c62..f684e22ad 100644 --- a/tpch/execute/q12.py +++ b/tpch/execute/q12.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q12 from . import IO_FUNCS diff --git a/tpch/execute/q13.py b/tpch/execute/q13.py index 2fdda5bd3..7b03a2f2f 100644 --- a/tpch/execute/q13.py +++ b/tpch/execute/q13.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q13 from . import IO_FUNCS diff --git a/tpch/execute/q14.py b/tpch/execute/q14.py index dfd54056e..a82330136 100644 --- a/tpch/execute/q14.py +++ b/tpch/execute/q14.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q14 from . import IO_FUNCS diff --git a/tpch/execute/q15.py b/tpch/execute/q15.py index 86a03b0a0..40b4432b1 100644 --- a/tpch/execute/q15.py +++ b/tpch/execute/q15.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q15 from . import IO_FUNCS diff --git a/tpch/execute/q16.py b/tpch/execute/q16.py index 6a70279d0..ef30f935c 100644 --- a/tpch/execute/q16.py +++ b/tpch/execute/q16.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q16 from . import IO_FUNCS diff --git a/tpch/execute/q17.py b/tpch/execute/q17.py index 43ef4f8b1..0b7ca4a66 100644 --- a/tpch/execute/q17.py +++ b/tpch/execute/q17.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q17 from . import IO_FUNCS diff --git a/tpch/execute/q18.py b/tpch/execute/q18.py index c7e5b7954..a096deb2f 100644 --- a/tpch/execute/q18.py +++ b/tpch/execute/q18.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q18 from . import IO_FUNCS diff --git a/tpch/execute/q19.py b/tpch/execute/q19.py index 60f91b052..23095a890 100644 --- a/tpch/execute/q19.py +++ b/tpch/execute/q19.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q19 from . import IO_FUNCS diff --git a/tpch/execute/q2.py b/tpch/execute/q2.py index cd82a9047..0e2d07019 100644 --- a/tpch/execute/q2.py +++ b/tpch/execute/q2.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q2 from . import IO_FUNCS diff --git a/tpch/execute/q20.py b/tpch/execute/q20.py index 3984b7580..c4ffa43b4 100644 --- a/tpch/execute/q20.py +++ b/tpch/execute/q20.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q20 from . import IO_FUNCS diff --git a/tpch/execute/q21.py b/tpch/execute/q21.py index 7cf772d8e..d6fb272ad 100644 --- a/tpch/execute/q21.py +++ b/tpch/execute/q21.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q21 from . import IO_FUNCS diff --git a/tpch/execute/q22.py b/tpch/execute/q22.py index a2bb1e76d..f71fc4220 100644 --- a/tpch/execute/q22.py +++ b/tpch/execute/q22.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q22 from . import IO_FUNCS diff --git a/tpch/execute/q3.py b/tpch/execute/q3.py index d6b9302cc..bbcc51d5c 100644 --- a/tpch/execute/q3.py +++ b/tpch/execute/q3.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q3 from . import IO_FUNCS diff --git a/tpch/execute/q4.py b/tpch/execute/q4.py index 5645574f8..bcfd3a158 100644 --- a/tpch/execute/q4.py +++ b/tpch/execute/q4.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q4 from . import IO_FUNCS diff --git a/tpch/execute/q5.py b/tpch/execute/q5.py index dcc61027b..66524c5a8 100644 --- a/tpch/execute/q5.py +++ b/tpch/execute/q5.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q5 from . import IO_FUNCS diff --git a/tpch/execute/q6.py b/tpch/execute/q6.py index 154964ff4..1d650b794 100644 --- a/tpch/execute/q6.py +++ b/tpch/execute/q6.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q6 from . import IO_FUNCS diff --git a/tpch/execute/q7.py b/tpch/execute/q7.py index a08d5641c..069fb258b 100644 --- a/tpch/execute/q7.py +++ b/tpch/execute/q7.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q7 from . import IO_FUNCS diff --git a/tpch/execute/q8.py b/tpch/execute/q8.py index a76a8051f..8c3aa5de9 100644 --- a/tpch/execute/q8.py +++ b/tpch/execute/q8.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q8 from . import IO_FUNCS diff --git a/tpch/execute/q9.py b/tpch/execute/q9.py index 14230af64..4c8e6874c 100644 --- a/tpch/execute/q9.py +++ b/tpch/execute/q9.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from queries import q9 from . import IO_FUNCS diff --git a/tpch/generate_data.py b/tpch/generate_data.py index 5fd73b1f7..d0a370a2a 100644 --- a/tpch/generate_data.py +++ b/tpch/generate_data.py @@ -1,4 +1,6 @@ -from pathlib import Path # noqa: INP001 +from __future__ import annotations + +from pathlib import Path import duckdb import pyarrow as pa diff --git a/tpch/queries/q1.py b/tpch/queries/q1.py index de6157702..a9c887b0a 100644 --- a/tpch/queries/q1.py +++ b/tpch/queries/q1.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q10.py b/tpch/queries/q10.py index 486e4ba82..b83d1e1b0 100644 --- a/tpch/queries/q10.py +++ b/tpch/queries/q10.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q11.py b/tpch/queries/q11.py index d5b48b359..66bacd593 100644 --- a/tpch/queries/q11.py +++ b/tpch/queries/q11.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q12.py b/tpch/queries/q12.py index ced775830..fb2a3dabe 100644 --- a/tpch/queries/q12.py +++ b/tpch/queries/q12.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q13.py b/tpch/queries/q13.py index adf57e5a2..e7499b158 100644 --- a/tpch/queries/q13.py +++ b/tpch/queries/q13.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q14.py b/tpch/queries/q14.py index f1ec6cbe3..44d176772 100644 --- a/tpch/queries/q14.py +++ b/tpch/queries/q14.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q15.py b/tpch/queries/q15.py index 1ebae57d6..f6a23dd30 100644 --- a/tpch/queries/q15.py +++ b/tpch/queries/q15.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q16.py b/tpch/queries/q16.py index d84b9aab5..f3609ae3d 100644 --- a/tpch/queries/q16.py +++ b/tpch/queries/q16.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q17.py b/tpch/queries/q17.py index 976f476f0..cf507efad 100644 --- a/tpch/queries/q17.py +++ b/tpch/queries/q17.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q18.py b/tpch/queries/q18.py index d3d183176..cdeeeca0a 100644 --- a/tpch/queries/q18.py +++ b/tpch/queries/q18.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q19.py b/tpch/queries/q19.py index bcab36e9a..63cb11dd3 100644 --- a/tpch/queries/q19.py +++ b/tpch/queries/q19.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q2.py b/tpch/queries/q2.py index 0e9e90d09..82c76bd34 100644 --- a/tpch/queries/q2.py +++ b/tpch/queries/q2.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q20.py b/tpch/queries/q20.py index b0dabb29e..0cb82e394 100644 --- a/tpch/queries/q20.py +++ b/tpch/queries/q20.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q21.py b/tpch/queries/q21.py index d10ff394f..5d6cc8784 100644 --- a/tpch/queries/q21.py +++ b/tpch/queries/q21.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q22.py b/tpch/queries/q22.py index 2e0973227..7bd76761f 100644 --- a/tpch/queries/q22.py +++ b/tpch/queries/q22.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q3.py b/tpch/queries/q3.py index 04679bccb..517d40154 100644 --- a/tpch/queries/q3.py +++ b/tpch/queries/q3.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q4.py b/tpch/queries/q4.py index a1b96be15..12a5cecd8 100644 --- a/tpch/queries/q4.py +++ b/tpch/queries/q4.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q5.py b/tpch/queries/q5.py index 2965868c9..39b402077 100644 --- a/tpch/queries/q5.py +++ b/tpch/queries/q5.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q6.py b/tpch/queries/q6.py index 67f0ac785..66b286b4b 100644 --- a/tpch/queries/q6.py +++ b/tpch/queries/q6.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q7.py b/tpch/queries/q7.py index ec0946ac3..576a1804c 100644 --- a/tpch/queries/q7.py +++ b/tpch/queries/q7.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import datetime +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q8.py b/tpch/queries/q8.py index ac3fa4baf..1ece5604b 100644 --- a/tpch/queries/q8.py +++ b/tpch/queries/q8.py @@ -1,7 +1,12 @@ +from __future__ import annotations + from datetime import date +from typing import TYPE_CHECKING import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/queries/q9.py b/tpch/queries/q9.py index 09dff4787..048538bc3 100644 --- a/tpch/queries/q9.py +++ b/tpch/queries/q9.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + import narwhals as nw -from narwhals.typing import FrameT + +if TYPE_CHECKING: + from narwhals.typing import FrameT @nw.narwhalify diff --git a/tpch/tests/queries_test.py b/tpch/tests/queries_test.py index 35909b683..c228fd52b 100644 --- a/tpch/tests/queries_test.py +++ b/tpch/tests/queries_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess import sys from pathlib import Path diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index e3aa0fb91..b7d8595aa 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import sys @@ -53,7 +55,7 @@ for i in content.splitlines() if i.startswith(" - ") ] -if missing := set(top_level_functions).difference(documented): +if missing := set(top_level_functions).difference(documented).difference({"annotations"}): print("top-level functions: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 diff --git a/utils/check_for_no_build_errors.py b/utils/check_for_no_build_errors.py index 995411e9d..48b5a9314 100644 --- a/utils/check_for_no_build_errors.py +++ b/utils/check_for_no_build_errors.py @@ -5,6 +5,8 @@ This is just used in CI. """ +from __future__ import annotations + import sys with open("output.txt") as fd: diff --git a/utils/generate_random_versions.py b/utils/generate_random_versions.py index ecb709c1a..7ad8e044d 100644 --- a/utils/generate_random_versions.py +++ b/utils/generate_random_versions.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import random PANDAS_AND_NUMPY_VERSION = [