From ecd3c233b3069568a42b40b6b85f531cd9c110c6 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Fri, 28 Jun 2024 07:38:02 +0200 Subject: [PATCH 1/2] Rename type_aliases module to _typing --- docs/user-guide/expressions/plugins.md | 2 +- .../polars/{type_aliases.py => _typing.py} | 6 +++--- .../polars/_utils/construction/dataframe.py | 4 ++-- py-polars/polars/_utils/construction/series.py | 2 +- py-polars/polars/_utils/convert.py | 2 +- py-polars/polars/_utils/deprecation.py | 2 +- py-polars/polars/_utils/getitem.py | 2 +- py-polars/polars/_utils/parse/expr.py | 2 +- py-polars/polars/_utils/serde.py | 2 +- py-polars/polars/_utils/various.py | 2 +- py-polars/polars/config.py | 2 +- py-polars/polars/convert/general.py | 2 +- py-polars/polars/dataframe/frame.py | 18 +++++++++--------- py-polars/polars/dataframe/group_by.py | 2 +- py-polars/polars/datatypes/_parse.py | 2 +- py-polars/polars/datatypes/_utils.py | 2 +- py-polars/polars/datatypes/classes.py | 2 +- py-polars/polars/datatypes/constants.py | 2 +- py-polars/polars/datatypes/constructor.py | 2 +- py-polars/polars/datatypes/convert.py | 2 +- py-polars/polars/datatypes/group.py | 2 +- py-polars/polars/expr/array.py | 2 +- py-polars/polars/expr/binary.py | 2 +- py-polars/polars/expr/datetime.py | 2 +- py-polars/polars/expr/expr.py | 8 ++++---- py-polars/polars/expr/list.py | 2 +- py-polars/polars/expr/meta.py | 2 +- py-polars/polars/expr/string.py | 2 +- py-polars/polars/expr/struct.py | 2 +- py-polars/polars/expr/whenthen.py | 2 +- .../polars/functions/aggregation/horizontal.py | 2 +- py-polars/polars/functions/as_datatype.py | 2 +- py-polars/polars/functions/business.py | 2 +- py-polars/polars/functions/col.py | 2 +- py-polars/polars/functions/eager.py | 4 ++-- py-polars/polars/functions/lazy.py | 2 +- py-polars/polars/functions/lit.py | 2 +- py-polars/polars/functions/range/date_range.py | 2 +- .../polars/functions/range/datetime_range.py | 2 +- py-polars/polars/functions/range/int_range.py | 2 +- py-polars/polars/functions/range/time_range.py | 2 +- py-polars/polars/functions/repeat.py | 2 +- py-polars/polars/functions/whenthen.py | 2 +- py-polars/polars/interchange/from_dataframe.py | 2 +- py-polars/polars/interchange/utils.py | 2 +- py-polars/polars/io/csv/batched_reader.py | 2 +- py-polars/polars/io/csv/functions.py | 2 +- py-polars/polars/io/database/_executor.py | 2 +- py-polars/polars/io/database/_inference.py | 2 +- py-polars/polars/io/database/_utils.py | 2 +- py-polars/polars/io/database/functions.py | 2 +- py-polars/polars/io/json/read.py | 2 +- py-polars/polars/io/ndjson.py | 2 +- py-polars/polars/io/parquet/functions.py | 2 +- .../polars/io/spreadsheet/_write_utils.py | 2 +- py-polars/polars/io/spreadsheet/functions.py | 2 +- py-polars/polars/lazyframe/frame.py | 4 ++-- py-polars/polars/lazyframe/group_by.py | 2 +- py-polars/polars/plugins.py | 2 +- py-polars/polars/selectors.py | 2 +- py-polars/polars/series/array.py | 2 +- py-polars/polars/series/binary.py | 2 +- py-polars/polars/series/datetime.py | 4 ++-- py-polars/polars/series/list.py | 4 ++-- py-polars/polars/series/series.py | 8 ++++---- py-polars/polars/series/string.py | 4 ++-- py-polars/polars/series/utils.py | 2 +- py-polars/polars/sql/context.py | 2 +- .../polars/testing/parametric/profiles.py | 2 +- .../testing/parametric/strategies/core.py | 2 +- .../testing/parametric/strategies/data.py | 2 +- .../testing/parametric/strategies/dtype.py | 2 +- .../testing/parametric/strategies/legacy.py | 2 +- .../constructors/test_any_value_fallbacks.py | 2 +- .../unit/constructors/test_constructors.py | 2 +- .../tests/unit/constructors/test_series.py | 2 +- py-polars/tests/unit/dataframe/test_df.py | 2 +- py-polars/tests/unit/dataframe/test_serde.py | 2 +- .../tests/unit/dataframe/test_upsample.py | 2 +- .../tests/unit/datatypes/test_categorical.py | 2 +- py-polars/tests/unit/datatypes/test_list.py | 2 +- py-polars/tests/unit/datatypes/test_parse.py | 2 +- py-polars/tests/unit/datatypes/test_struct.py | 2 +- .../tests/unit/datatypes/test_temporal.py | 2 +- py-polars/tests/unit/expr/test_exprs.py | 2 +- .../functions/as_datatype/test_datetime.py | 2 +- .../functions/as_datatype/test_duration.py | 2 +- .../unit/functions/range/test_date_range.py | 2 +- .../functions/range/test_datetime_range.py | 2 +- .../unit/functions/range/test_time_range.py | 2 +- .../tests/unit/functions/test_functions.py | 2 +- py-polars/tests/unit/functions/test_lit.py | 2 +- py-polars/tests/unit/functions/test_repeat.py | 2 +- .../tests/unit/interchange/test_roundtrip.py | 2 +- py-polars/tests/unit/interchange/test_utils.py | 2 +- .../unit/interop/numpy/test_from_numpy_df.py | 2 +- .../interop/numpy/test_from_numpy_series.py | 2 +- .../unit/interop/numpy/test_to_numpy_df.py | 2 +- .../unit/interop/numpy/test_to_numpy_series.py | 2 +- py-polars/tests/unit/interop/test_interop.py | 2 +- py-polars/tests/unit/interop/test_to_pandas.py | 2 +- .../tests/unit/io/database/test_inference.py | 2 +- py-polars/tests/unit/io/database/test_read.py | 2 +- py-polars/tests/unit/io/database/test_write.py | 2 +- py-polars/tests/unit/io/test_avro.py | 2 +- py-polars/tests/unit/io/test_csv.py | 2 +- py-polars/tests/unit/io/test_ipc.py | 2 +- py-polars/tests/unit/io/test_lazy_parquet.py | 2 +- py-polars/tests/unit/io/test_parquet.py | 2 +- py-polars/tests/unit/io/test_scan.py | 2 +- py-polars/tests/unit/io/test_spreadsheet.py | 2 +- .../tests/unit/lazyframe/test_lazyframe.py | 2 +- py-polars/tests/unit/lazyframe/test_serde.py | 2 +- py-polars/tests/unit/ml/test_to_jax.py | 2 +- .../aggregation/test_aggregations.py | 2 +- .../operations/aggregation/test_horizontal.py | 2 +- .../unit/operations/arithmetic/test_neg.py | 2 +- .../temporal/test_add_business_days.py | 2 +- .../namespaces/temporal/test_datetime.py | 2 +- .../namespaces/temporal/test_offset_by.py | 2 +- .../namespaces/temporal/test_to_datetime.py | 2 +- .../namespaces/temporal/test_truncate.py | 2 +- .../unit/operations/namespaces/test_binary.py | 2 +- .../operations/namespaces/test_strptime.py | 2 +- .../tests/unit/operations/rolling/test_map.py | 2 +- .../unit/operations/rolling/test_rolling.py | 2 +- py-polars/tests/unit/operations/test_abs.py | 2 +- py-polars/tests/unit/operations/test_cast.py | 2 +- .../tests/unit/operations/test_comparison.py | 2 +- py-polars/tests/unit/operations/test_ewm_by.py | 2 +- .../unit/operations/test_extend_constant.py | 2 +- py-polars/tests/unit/operations/test_filter.py | 2 +- .../tests/unit/operations/test_group_by.py | 2 +- .../unit/operations/test_group_by_dynamic.py | 2 +- .../tests/unit/operations/test_interpolate.py | 2 +- .../unit/operations/test_interpolate_by.py | 2 +- .../operations/test_is_first_last_distinct.py | 2 +- py-polars/tests/unit/operations/test_is_in.py | 2 +- py-polars/tests/unit/operations/test_join.py | 2 +- py-polars/tests/unit/operations/test_pivot.py | 2 +- .../tests/unit/operations/test_rolling.py | 2 +- py-polars/tests/unit/operations/test_sort.py | 2 +- py-polars/tests/unit/series/test_series.py | 2 +- py-polars/tests/unit/sql/test_numeric.py | 2 +- .../tests/unit/streaming/test_streaming.py | 2 +- .../unit/streaming/test_streaming_join.py | 2 +- py-polars/tests/unit/test_datatypes.py | 2 +- py-polars/tests/unit/test_errors.py | 2 +- py-polars/tests/unit/test_format.py | 2 +- py-polars/tests/unit/test_selectors.py | 2 +- py-polars/tests/unit/utils/test_utils.py | 2 +- 151 files changed, 173 insertions(+), 173 deletions(-) rename py-polars/polars/{type_aliases.py => _typing.py} (98%) diff --git a/docs/user-guide/expressions/plugins.md b/docs/user-guide/expressions/plugins.md index 156a11657ff9..a75066baf98c 100644 --- a/docs/user-guide/expressions/plugins.md +++ b/docs/user-guide/expressions/plugins.md @@ -97,7 +97,7 @@ from typing import TYPE_CHECKING import polars as pl from polars.plugins import register_plugin_function -from polars.type_aliases import IntoExpr +from polars._typing import IntoExpr def pig_latinnify(expr: IntoExpr) -> pl.Expr: diff --git a/py-polars/polars/type_aliases.py b/py-polars/polars/_typing.py similarity index 98% rename from py-polars/polars/type_aliases.py rename to py-polars/polars/_typing.py index 279ca6f85b0e..bc2a3714c06c 100644 --- a/py-polars/polars/type_aliases.py +++ b/py-polars/polars/_typing.py @@ -229,17 +229,17 @@ class SeriesBuffers(TypedDict): # minimal protocol definitions that can reasonably represent # an executable connection, cursor, or equivalent object -class BasicConnection(Protocol): # noqa: D101 +class BasicConnection(Protocol): def cursor(self, *args: Any, **kwargs: Any) -> Any: """Return a cursor object.""" -class BasicCursor(Protocol): # noqa: D101 +class BasicCursor(Protocol): def execute(self, *args: Any, **kwargs: Any) -> Any: """Execute a query.""" -class Cursor(BasicCursor): # noqa: D101 +class Cursor(BasicCursor): def fetchall(self, *args: Any, **kwargs: Any) -> Any: """Fetch all results.""" diff --git a/py-polars/polars/_utils/construction/dataframe.py b/py-polars/polars/_utils/construction/dataframe.py index 7f15c38cb90d..54e340c36248 100644 --- a/py-polars/polars/_utils/construction/dataframe.py +++ b/py-polars/polars/_utils/construction/dataframe.py @@ -63,13 +63,13 @@ if TYPE_CHECKING: from polars import DataFrame, Series - from polars.polars import PySeries - from polars.type_aliases import ( + from polars._typing import ( Orientation, PolarsDataType, SchemaDefinition, SchemaDict, ) + from polars.polars import PySeries _MIN_NUMPY_SIZE_FOR_MULTITHREADING = 1000 diff --git a/py-polars/polars/_utils/construction/series.py b/py-polars/polars/_utils/construction/series.py index a045e34cdd73..7ab7ba283f1d 100644 --- a/py-polars/polars/_utils/construction/series.py +++ b/py-polars/polars/_utils/construction/series.py @@ -66,8 +66,8 @@ if TYPE_CHECKING: from polars import DataFrame, Series + from polars._typing import PolarsDataType from polars.dependencies import pandas as pd - from polars.type_aliases import PolarsDataType def sequence_to_pyseries( diff --git a/py-polars/polars/_utils/convert.py b/py-polars/polars/_utils/convert.py index 894f870ca91b..e2f4066c62de 100644 --- a/py-polars/polars/_utils/convert.py +++ b/py-polars/polars/_utils/convert.py @@ -29,7 +29,7 @@ from datetime import date, tzinfo from decimal import Decimal - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit @overload diff --git a/py-polars/polars/_utils/deprecation.py b/py-polars/polars/_utils/deprecation.py index b0d6f7677c6a..bf93cff116f7 100644 --- a/py-polars/polars/_utils/deprecation.py +++ b/py-polars/polars/_utils/deprecation.py @@ -10,7 +10,7 @@ import sys from typing import Mapping - from polars.type_aliases import Ambiguous + from polars._typing import Ambiguous if sys.version_info >= (3, 10): from typing import ParamSpec diff --git a/py-polars/polars/_utils/getitem.py b/py-polars/polars/_utils/getitem.py index d6faaaa679a5..7dd0e24cef5d 100644 --- a/py-polars/polars/_utils/getitem.py +++ b/py-polars/polars/_utils/getitem.py @@ -23,7 +23,7 @@ if TYPE_CHECKING: from polars import DataFrame, Series - from polars.type_aliases import ( + from polars._typing import ( MultiColSelector, MultiIndexSelector, SingleColSelector, diff --git a/py-polars/polars/_utils/parse/expr.py b/py-polars/polars/_utils/parse/expr.py index 484d68c60978..69e372ae6219 100644 --- a/py-polars/polars/_utils/parse/expr.py +++ b/py-polars/polars/_utils/parse/expr.py @@ -12,8 +12,8 @@ if TYPE_CHECKING: from polars import Expr + from polars._typing import IntoExpr, PolarsDataType from polars.polars import PyExpr - from polars.type_aliases import IntoExpr, PolarsDataType def parse_into_expression( diff --git a/py-polars/polars/_utils/serde.py b/py-polars/polars/_utils/serde.py index 9a6e19824bdb..af6e1416911e 100644 --- a/py-polars/polars/_utils/serde.py +++ b/py-polars/polars/_utils/serde.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from io import IOBase - from polars.type_aliases import SerializationFormat + from polars._typing import SerializationFormat @overload diff --git a/py-polars/polars/_utils/various.py b/py-polars/polars/_utils/various.py index d9a7dc54eeab..b14a3841103c 100644 --- a/py-polars/polars/_utils/various.py +++ b/py-polars/polars/_utils/various.py @@ -40,7 +40,7 @@ from collections.abc import Iterator, Reversible from polars import DataFrame - from polars.type_aliases import PolarsDataType, SizeUnit + from polars._typing import PolarsDataType, SizeUnit if sys.version_info >= (3, 13): from typing import TypeIs diff --git a/py-polars/polars/config.py b/py-polars/polars/config.py index b922df977ff0..6cb01bdafb9e 100644 --- a/py-polars/polars/config.py +++ b/py-polars/polars/config.py @@ -12,7 +12,7 @@ import sys from types import TracebackType - from polars.type_aliases import FloatFmt + from polars._typing import FloatFmt if sys.version_info >= (3, 10): from typing import TypeAlias diff --git a/py-polars/polars/convert/general.py b/py-polars/polars/convert/general.py index e04360b2c7f6..cc059ccba55e 100644 --- a/py-polars/polars/convert/general.py +++ b/py-polars/polars/convert/general.py @@ -25,9 +25,9 @@ if TYPE_CHECKING: from polars import DataFrame, Series + from polars._typing import Orientation, SchemaDefinition, SchemaDict from polars.dependencies import numpy as np from polars.interchange.protocol import SupportsInterchange - from polars.type_aliases import Orientation, SchemaDefinition, SchemaDict def from_dict( diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 9ecb5b92c104..a660e26fb18c 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -31,6 +31,11 @@ import polars._reexport as pl from polars import functions as F +from polars._typing import ( + DbWriteMode, + JaxExportType, + TorchExportType, +) from polars._utils.construction import ( arrow_to_pydf, dataframe_to_pydf, @@ -101,11 +106,6 @@ from polars.functions import col, lit from polars.schema import Schema from polars.selectors import _expand_selector_dicts, _expand_selectors -from polars.type_aliases import ( - DbWriteMode, - JaxExportType, - TorchExportType, -) with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PyDataFrame @@ -127,10 +127,7 @@ from xlsxwriter import Workbook from polars import DataType, Expr, LazyFrame, Series - from polars._utils.various import NoDefault - from polars.interchange.dataframe import PolarsDataFrame - from polars.ml.torch import PolarsDataset - from polars.type_aliases import ( + from polars._typing import ( AsofJoinStrategy, AvroCompression, ClosedInterval, @@ -172,6 +169,9 @@ UniqueKeepStrategy, UnstackDirection, ) + from polars._utils.various import NoDefault + from polars.interchange.dataframe import PolarsDataFrame + from polars.ml.torch import PolarsDataset if sys.version_info >= (3, 10): from typing import Concatenate, ParamSpec diff --git a/py-polars/polars/dataframe/group_by.py b/py-polars/polars/dataframe/group_by.py index 9350bdc14717..0687313b844f 100644 --- a/py-polars/polars/dataframe/group_by.py +++ b/py-polars/polars/dataframe/group_by.py @@ -11,7 +11,7 @@ from datetime import timedelta from polars import DataFrame - from polars.type_aliases import ( + from polars._typing import ( ClosedInterval, IntoExpr, Label, diff --git a/py-polars/polars/datatypes/_parse.py b/py-polars/polars/datatypes/_parse.py index 84cf3049c1dc..55345909c925 100644 --- a/py-polars/polars/datatypes/_parse.py +++ b/py-polars/polars/datatypes/_parse.py @@ -25,7 +25,7 @@ from polars.datatypes.convert import is_polars_dtype if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType, PythonDataType, SchemaDict + from polars._typing import PolarsDataType, PythonDataType, SchemaDict UnionTypeOld = type(Union[int, str]) diff --git a/py-polars/polars/datatypes/_utils.py b/py-polars/polars/datatypes/_utils.py index a718b117d0e6..af2c639fc5f4 100644 --- a/py-polars/polars/datatypes/_utils.py +++ b/py-polars/polars/datatypes/_utils.py @@ -1,7 +1,7 @@ """Utility functions for handling and processing of datatypes.""" +from polars._typing import PolarsDataType from polars.datatypes.classes import Array, List, Struct -from polars.type_aliases import PolarsDataType def dtype_to_init_repr(dtype: PolarsDataType, prefix: str = "pl.") -> str: diff --git a/py-polars/polars/datatypes/classes.py b/py-polars/polars/datatypes/classes.py index 6ab3630ade01..08aeb53c5674 100644 --- a/py-polars/polars/datatypes/classes.py +++ b/py-polars/polars/datatypes/classes.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: from polars import Series - from polars.type_aliases import ( + from polars._typing import ( CategoricalOrdering, PolarsDataType, PythonDataType, diff --git a/py-polars/polars/datatypes/constants.py b/py-polars/polars/datatypes/constants.py index b0eed7097f61..66306775df21 100644 --- a/py-polars/polars/datatypes/constants.py +++ b/py-polars/polars/datatypes/constants.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit # Number of rows to scan by default when inferring datatypes N_INFER_DEFAULT = 100 diff --git a/py-polars/polars/datatypes/constructor.py b/py-polars/polars/datatypes/constructor.py index 641003173491..63e0d912cbf8 100644 --- a/py-polars/polars/datatypes/constructor.py +++ b/py-polars/polars/datatypes/constructor.py @@ -16,7 +16,7 @@ _DOCUMENTING = True if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType if not _DOCUMENTING: _POLARS_TYPE_TO_CONSTRUCTOR: dict[ diff --git a/py-polars/polars/datatypes/convert.py b/py-polars/polars/datatypes/convert.py index 5ab2af72e1b6..a965422c7530 100644 --- a/py-polars/polars/datatypes/convert.py +++ b/py-polars/polars/datatypes/convert.py @@ -54,7 +54,7 @@ UnionType = type(Union[int, float]) if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType, PythonDataType, TimeUnit + from polars._typing import PolarsDataType, PythonDataType, TimeUnit if sys.version_info >= (3, 10): from typing import TypeGuard diff --git a/py-polars/polars/datatypes/group.py b/py-polars/polars/datatypes/group.py index aafe7ad52b81..1cf67c7eba22 100644 --- a/py-polars/polars/datatypes/group.py +++ b/py-polars/polars/datatypes/group.py @@ -26,7 +26,7 @@ ) if TYPE_CHECKING: - from polars.type_aliases import ( + from polars._typing import ( PolarsDataType, PolarsIntegerType, PolarsTemporalType, diff --git a/py-polars/polars/expr/array.py b/py-polars/polars/expr/array.py index b2eb815c775d..85b21f6c5573 100644 --- a/py-polars/polars/expr/array.py +++ b/py-polars/polars/expr/array.py @@ -9,7 +9,7 @@ from datetime import date, datetime, time from polars import Expr - from polars.type_aliases import IntoExpr, IntoExprColumn + from polars._typing import IntoExpr, IntoExprColumn class ExprArrayNameSpace: diff --git a/py-polars/polars/expr/binary.py b/py-polars/polars/expr/binary.py index 457d1d43bef0..7fdde32cc7f5 100644 --- a/py-polars/polars/expr/binary.py +++ b/py-polars/polars/expr/binary.py @@ -7,7 +7,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import IntoExpr, TransferEncoding + from polars._typing import IntoExpr, TransferEncoding class ExprBinaryNameSpace: diff --git a/py-polars/polars/expr/datetime.py b/py-polars/polars/expr/datetime.py index 2072634c787f..59e481d2995d 100644 --- a/py-polars/polars/expr/datetime.py +++ b/py-polars/polars/expr/datetime.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import ( + from polars._typing import ( Ambiguous, EpochTimeUnit, IntoExpr, diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index 78989ca5cc1a..81597ac5b7ac 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -72,10 +72,7 @@ from io import IOBase from polars import DataFrame, LazyFrame, Series - from polars._utils.various import ( - NoDefault, - ) - from polars.type_aliases import ( + from polars._typing import ( ClosedInterval, FillNullStrategy, InterpolationMethod, @@ -92,6 +89,9 @@ TemporalLiteral, WindowMappingStrategy, ) + from polars._utils.various import ( + NoDefault, + ) if sys.version_info >= (3, 11): from typing import Concatenate, ParamSpec diff --git a/py-polars/polars/expr/list.py b/py-polars/polars/expr/list.py index 6ac7a18518dc..390904997697 100644 --- a/py-polars/polars/expr/list.py +++ b/py-polars/polars/expr/list.py @@ -12,7 +12,7 @@ from datetime import date, datetime, time from polars import Expr, Series - from polars.type_aliases import ( + from polars._typing import ( IntoExpr, IntoExprColumn, NullBehavior, diff --git a/py-polars/polars/expr/meta.py b/py-polars/polars/expr/meta.py index d409050b7af6..333b35351a2d 100644 --- a/py-polars/polars/expr/meta.py +++ b/py-polars/polars/expr/meta.py @@ -12,7 +12,7 @@ from pathlib import Path from polars import Expr - from polars.type_aliases import SerializationFormat + from polars._typing import SerializationFormat class ExprMetaNameSpace: diff --git a/py-polars/polars/expr/string.py b/py-polars/polars/expr/string.py index 995406fedf33..707cefaa41aa 100644 --- a/py-polars/polars/expr/string.py +++ b/py-polars/polars/expr/string.py @@ -18,7 +18,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import ( + from polars._typing import ( Ambiguous, IntoExpr, IntoExprColumn, diff --git a/py-polars/polars/expr/struct.py b/py-polars/polars/expr/struct.py index c2d73c48d122..225f82b67199 100644 --- a/py-polars/polars/expr/struct.py +++ b/py-polars/polars/expr/struct.py @@ -8,7 +8,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import IntoExpr + from polars._typing import IntoExpr class ExprStructNameSpace: diff --git a/py-polars/polars/expr/whenthen.py b/py-polars/polars/expr/whenthen.py index 2c8430041301..1467d9e73698 100644 --- a/py-polars/polars/expr/whenthen.py +++ b/py-polars/polars/expr/whenthen.py @@ -11,8 +11,8 @@ from polars.expr.expr import Expr if TYPE_CHECKING: + from polars._typing import IntoExpr from polars.polars import PyExpr - from polars.type_aliases import IntoExpr class When: diff --git a/py-polars/polars/functions/aggregation/horizontal.py b/py-polars/polars/functions/aggregation/horizontal.py index 45457d5a3cd2..121f1bb41497 100644 --- a/py-polars/polars/functions/aggregation/horizontal.py +++ b/py-polars/polars/functions/aggregation/horizontal.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import IntoExpr + from polars._typing import IntoExpr def all_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: diff --git a/py-polars/polars/functions/as_datatype.py b/py-polars/polars/functions/as_datatype.py index d0381e56ec71..d09a8cead6dc 100644 --- a/py-polars/polars/functions/as_datatype.py +++ b/py-polars/polars/functions/as_datatype.py @@ -19,7 +19,7 @@ from typing import Literal from polars import Expr, Series - from polars.type_aliases import Ambiguous, IntoExpr, SchemaDict, TimeUnit + from polars._typing import Ambiguous, IntoExpr, SchemaDict, TimeUnit def datetime_( diff --git a/py-polars/polars/functions/business.py b/py-polars/polars/functions/business.py index fe5617d048de..dc70a4ba3679 100644 --- a/py-polars/polars/functions/business.py +++ b/py-polars/polars/functions/business.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import IntoExprColumn + from polars._typing import IntoExprColumn def business_day_count( diff --git a/py-polars/polars/functions/col.py b/py-polars/polars/functions/col.py index 3da4ce383551..4df9fc8ea1b3 100644 --- a/py-polars/polars/functions/col.py +++ b/py-polars/polars/functions/col.py @@ -11,8 +11,8 @@ import polars.polars as plr # type: ignore[no-redef] if TYPE_CHECKING: + from polars._typing import PolarsDataType from polars.expr.expr import Expr - from polars.type_aliases import PolarsDataType __all__ = ["col"] diff --git a/py-polars/polars/functions/eager.py b/py-polars/polars/functions/eager.py index d847efed244a..a841520be8c5 100644 --- a/py-polars/polars/functions/eager.py +++ b/py-polars/polars/functions/eager.py @@ -7,17 +7,17 @@ import polars._reexport as pl from polars import functions as F +from polars._typing import ConcatMethod from polars._utils.various import ordered_unique from polars._utils.wrap import wrap_df, wrap_expr, wrap_ldf, wrap_s from polars.exceptions import InvalidOperationError -from polars.type_aliases import ConcatMethod with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr if TYPE_CHECKING: from polars import DataFrame, Expr, LazyFrame, Series - from polars.type_aliases import FrameType, JoinStrategy, PolarsType + from polars._typing import FrameType, JoinStrategy, PolarsType def concat( diff --git a/py-polars/polars/functions/lazy.py b/py-polars/polars/functions/lazy.py index 5744e7c83d29..b414661cce2d 100644 --- a/py-polars/polars/functions/lazy.py +++ b/py-polars/polars/functions/lazy.py @@ -23,7 +23,7 @@ from typing import Awaitable, Collection, Literal from polars import DataFrame, Expr, LazyFrame, Series - from polars.type_aliases import ( + from polars._typing import ( CorrelationMethod, EpochTimeUnit, IntoExpr, diff --git a/py-polars/polars/functions/lit.py b/py-polars/polars/functions/lit.py index 11ec98a08fda..92d43f88b726 100644 --- a/py-polars/polars/functions/lit.py +++ b/py-polars/polars/functions/lit.py @@ -23,7 +23,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import PolarsDataType, TimeUnit + from polars._typing import PolarsDataType, TimeUnit def lit( diff --git a/py-polars/polars/functions/range/date_range.py b/py-polars/polars/functions/range/date_range.py index 6b47e3281ab2..1ed407194a3d 100644 --- a/py-polars/polars/functions/range/date_range.py +++ b/py-polars/polars/functions/range/date_range.py @@ -16,7 +16,7 @@ from typing import Literal from polars import Expr, Series - from polars.type_aliases import ClosedInterval, IntoExprColumn + from polars._typing import ClosedInterval, IntoExprColumn @overload diff --git a/py-polars/polars/functions/range/datetime_range.py b/py-polars/polars/functions/range/datetime_range.py index f57b42712dda..3fe2c2767481 100644 --- a/py-polars/polars/functions/range/datetime_range.py +++ b/py-polars/polars/functions/range/datetime_range.py @@ -16,7 +16,7 @@ from typing import Literal from polars import Expr, Series - from polars.type_aliases import ClosedInterval, IntoExprColumn, TimeUnit + from polars._typing import ClosedInterval, IntoExprColumn, TimeUnit @overload diff --git a/py-polars/polars/functions/range/int_range.py b/py-polars/polars/functions/range/int_range.py index 00d39a760e19..1aa37620006a 100644 --- a/py-polars/polars/functions/range/int_range.py +++ b/py-polars/polars/functions/range/int_range.py @@ -15,7 +15,7 @@ from typing import Literal from polars import Expr, Series - from polars.type_aliases import IntoExprColumn, PolarsIntegerType + from polars._typing import IntoExprColumn, PolarsIntegerType @overload diff --git a/py-polars/polars/functions/range/time_range.py b/py-polars/polars/functions/range/time_range.py index f0a5af260b37..75377fec510c 100644 --- a/py-polars/polars/functions/range/time_range.py +++ b/py-polars/polars/functions/range/time_range.py @@ -17,7 +17,7 @@ from typing import Literal from polars import Expr, Series - from polars.type_aliases import ClosedInterval, IntoExprColumn + from polars._typing import ClosedInterval, IntoExprColumn @overload diff --git a/py-polars/polars/functions/repeat.py b/py-polars/polars/functions/repeat.py index c23aa8c2fac6..5c8afc98864b 100644 --- a/py-polars/polars/functions/repeat.py +++ b/py-polars/polars/functions/repeat.py @@ -26,7 +26,7 @@ from typing import Literal from polars import Expr, Series - from polars.type_aliases import IntoExpr, PolarsDataType + from polars._typing import IntoExpr, PolarsDataType # create a lookup of dtypes that have a reasonable one/zero mapping; for diff --git a/py-polars/polars/functions/whenthen.py b/py-polars/polars/functions/whenthen.py index 7fb6ed59a112..e72708d311e7 100644 --- a/py-polars/polars/functions/whenthen.py +++ b/py-polars/polars/functions/whenthen.py @@ -10,7 +10,7 @@ import polars.polars as plr if TYPE_CHECKING: - from polars.type_aliases import IntoExprColumn + from polars._typing import IntoExprColumn def when( diff --git a/py-polars/polars/interchange/from_dataframe.py b/py-polars/polars/interchange/from_dataframe.py index 67e93f6951b7..6b876abd4ece 100644 --- a/py-polars/polars/interchange/from_dataframe.py +++ b/py-polars/polars/interchange/from_dataframe.py @@ -16,9 +16,9 @@ if TYPE_CHECKING: from polars import DataFrame, Series + from polars._typing import PolarsDataType from polars.interchange.protocol import Buffer, Column, Dtype, SupportsInterchange from polars.interchange.protocol import DataFrame as InterchangeDataFrame - from polars.type_aliases import PolarsDataType def from_dataframe(df: SupportsInterchange, *, allow_copy: bool = True) -> DataFrame: diff --git a/py-polars/polars/interchange/utils.py b/py-polars/polars/interchange/utils.py index ce0ab95010fe..5e4fa7d37302 100644 --- a/py-polars/polars/interchange/utils.py +++ b/py-polars/polars/interchange/utils.py @@ -26,9 +26,9 @@ from polars.interchange.protocol import DtypeKind, Endianness if TYPE_CHECKING: + from polars._typing import PolarsDataType from polars.datatypes import DataTypeClass from polars.interchange.protocol import Dtype - from polars.type_aliases import PolarsDataType NE = Endianness.NATIVE diff --git a/py-polars/polars/io/csv/batched_reader.py b/py-polars/polars/io/csv/batched_reader.py index baf4a6c6f936..57cca5d366d3 100644 --- a/py-polars/polars/io/csv/batched_reader.py +++ b/py-polars/polars/io/csv/batched_reader.py @@ -19,7 +19,7 @@ from pathlib import Path from polars import DataFrame - from polars.type_aliases import CsvEncoding, PolarsDataType, SchemaDict + from polars._typing import CsvEncoding, PolarsDataType, SchemaDict class BatchedCsvReader: diff --git a/py-polars/polars/io/csv/functions.py b/py-polars/polars/io/csv/functions.py index 1c2634f2281e..a3518a2d68e7 100644 --- a/py-polars/polars/io/csv/functions.py +++ b/py-polars/polars/io/csv/functions.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: from polars import DataFrame, LazyFrame - from polars.type_aliases import CsvEncoding, PolarsDataType, SchemaDict + from polars._typing import CsvEncoding, PolarsDataType, SchemaDict @deprecate_renamed_parameter("dtypes", "schema_overrides", version="0.20.31") diff --git a/py-polars/polars/io/database/_executor.py b/py-polars/polars/io/database/_executor.py index d4d9e88f7884..67492a8bee59 100644 --- a/py-polars/polars/io/database/_executor.py +++ b/py-polars/polars/io/database/_executor.py @@ -37,7 +37,7 @@ from typing_extensions import Self from polars import DataFrame - from polars.type_aliases import ConnectionOrCursor, Cursor, SchemaDict + from polars._typing import ConnectionOrCursor, Cursor, SchemaDict try: from sqlalchemy.sql.expression import Selectable diff --git a/py-polars/polars/io/database/_inference.py b/py-polars/polars/io/database/_inference.py index 601e5ddd6514..f9045e00bdb6 100644 --- a/py-polars/polars/io/database/_inference.py +++ b/py-polars/polars/io/database/_inference.py @@ -35,7 +35,7 @@ ) if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def _infer_dtype_from_database_typename( diff --git a/py-polars/polars/io/database/_utils.py b/py-polars/polars/io/database/_utils.py index 50d0f72dca6e..c67b4cc9d631 100644 --- a/py-polars/polars/io/database/_utils.py +++ b/py-polars/polars/io/database/_utils.py @@ -16,7 +16,7 @@ from typing_extensions import TypeAlias from polars import DataFrame - from polars.type_aliases import SchemaDict + from polars._typing import SchemaDict try: from sqlalchemy.sql.expression import Selectable diff --git a/py-polars/polars/io/database/functions.py b/py-polars/polars/io/database/functions.py index 87d0f44c2a06..fe0142601a66 100644 --- a/py-polars/polars/io/database/functions.py +++ b/py-polars/polars/io/database/functions.py @@ -17,7 +17,7 @@ from typing_extensions import TypeAlias from polars import DataFrame - from polars.type_aliases import ConnectionOrCursor, DbReadEngine, SchemaDict + from polars._typing import ConnectionOrCursor, DbReadEngine, SchemaDict try: from sqlalchemy.sql.expression import Selectable diff --git a/py-polars/polars/io/json/read.py b/py-polars/polars/io/json/read.py index 450b5daeeead..d34aa69025e7 100644 --- a/py-polars/polars/io/json/read.py +++ b/py-polars/polars/io/json/read.py @@ -16,7 +16,7 @@ from io import IOBase from polars import DataFrame - from polars.type_aliases import SchemaDefinition + from polars._typing import SchemaDefinition def read_json( diff --git a/py-polars/polars/io/ndjson.py b/py-polars/polars/io/ndjson.py index d129a9da8e52..d498d1323489 100644 --- a/py-polars/polars/io/ndjson.py +++ b/py-polars/polars/io/ndjson.py @@ -18,7 +18,7 @@ from io import IOBase from polars import DataFrame, LazyFrame - from polars.type_aliases import SchemaDefinition + from polars._typing import SchemaDefinition def read_ndjson( diff --git a/py-polars/polars/io/parquet/functions.py b/py-polars/polars/io/parquet/functions.py index 9e9e93f5875c..8daeb00d6aea 100644 --- a/py-polars/polars/io/parquet/functions.py +++ b/py-polars/polars/io/parquet/functions.py @@ -27,7 +27,7 @@ if TYPE_CHECKING: from polars import DataFrame, DataType, LazyFrame - from polars.type_aliases import ParallelStrategy, SchemaDict + from polars._typing import ParallelStrategy, SchemaDict @deprecate_renamed_parameter("row_count_name", "row_index_name", version="0.20.4") diff --git a/py-polars/polars/io/spreadsheet/_write_utils.py b/py-polars/polars/io/spreadsheet/_write_utils.py index 3dc8e15a206f..505cb4c9365f 100644 --- a/py-polars/polars/io/spreadsheet/_write_utils.py +++ b/py-polars/polars/io/spreadsheet/_write_utils.py @@ -27,7 +27,7 @@ from xlsxwriter.worksheet import Worksheet from polars import DataFrame, Series - from polars.type_aliases import ( + from polars._typing import ( ColumnFormatDict, ColumnTotalsDefinition, ConditionalFormatDict, diff --git a/py-polars/polars/io/spreadsheet/functions.py b/py-polars/polars/io/spreadsheet/functions.py index 26af04440cd1..4b907d14fa48 100644 --- a/py-polars/polars/io/spreadsheet/functions.py +++ b/py-polars/polars/io/spreadsheet/functions.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: from typing import Literal - from polars.type_aliases import ExcelSpreadsheetEngine, SchemaDict + from polars._typing import ExcelSpreadsheetEngine, SchemaDict @overload diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index b3a76510f11b..171ce9afd169 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -94,8 +94,7 @@ import pyarrow as pa from polars import DataFrame, DataType, Expr - from polars.dependencies import numpy as np - from polars.type_aliases import ( + from polars._typing import ( AsofJoinStrategy, ClosedInterval, ColumnNameOrSelector, @@ -117,6 +116,7 @@ StartBy, UniqueKeepStrategy, ) + from polars.dependencies import numpy as np if sys.version_info >= (3, 10): from typing import Concatenate, ParamSpec diff --git a/py-polars/polars/lazyframe/group_by.py b/py-polars/polars/lazyframe/group_by.py index 485f9ea62331..0a42a1b9a808 100644 --- a/py-polars/polars/lazyframe/group_by.py +++ b/py-polars/polars/lazyframe/group_by.py @@ -9,8 +9,8 @@ if TYPE_CHECKING: from polars import DataFrame, LazyFrame + from polars._typing import IntoExpr, RollingInterpolationMethod, SchemaDict from polars.polars import PyLazyGroupBy - from polars.type_aliases import IntoExpr, RollingInterpolationMethod, SchemaDict class LazyGroupBy: diff --git a/py-polars/polars/plugins.py b/py-polars/polars/plugins.py index 7ff0e2db6ac5..b1a16e57c3c1 100644 --- a/py-polars/polars/plugins.py +++ b/py-polars/polars/plugins.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from polars import Expr - from polars.type_aliases import IntoExpr + from polars._typing import IntoExpr __all__ = ["register_plugin_function"] diff --git a/py-polars/polars/selectors.py b/py-polars/polars/selectors.py index 628c4d9fddb0..81f6ae976799 100644 --- a/py-polars/polars/selectors.py +++ b/py-polars/polars/selectors.py @@ -44,7 +44,7 @@ import sys from polars import DataFrame, LazyFrame - from polars.type_aliases import PolarsDataType, SelectorType, TimeUnit + from polars._typing import PolarsDataType, SelectorType, TimeUnit if sys.version_info >= (3, 11): from typing import Self diff --git a/py-polars/polars/series/array.py b/py-polars/polars/series/array.py index 2e274ce23a1a..c7f70e945bbf 100644 --- a/py-polars/polars/series/array.py +++ b/py-polars/polars/series/array.py @@ -10,8 +10,8 @@ from datetime import date, datetime, time from polars import Series + from polars._typing import IntoExpr, IntoExprColumn from polars.polars import PySeries - from polars.type_aliases import IntoExpr, IntoExprColumn @expr_dispatch diff --git a/py-polars/polars/series/binary.py b/py-polars/polars/series/binary.py index 2796ecb403eb..c7a82a245717 100644 --- a/py-polars/polars/series/binary.py +++ b/py-polars/polars/series/binary.py @@ -6,8 +6,8 @@ if TYPE_CHECKING: from polars import Series + from polars._typing import IntoExpr, TransferEncoding from polars.polars import PySeries - from polars.type_aliases import IntoExpr, TransferEncoding @expr_dispatch diff --git a/py-polars/polars/series/datetime.py b/py-polars/polars/series/datetime.py index c6d04a1e289d..c65e822e1044 100644 --- a/py-polars/polars/series/datetime.py +++ b/py-polars/polars/series/datetime.py @@ -11,8 +11,7 @@ import datetime as dt from polars import Expr, Series - from polars.polars import PySeries - from polars.type_aliases import ( + from polars._typing import ( Ambiguous, EpochTimeUnit, IntoExpr, @@ -22,6 +21,7 @@ TemporalLiteral, TimeUnit, ) + from polars.polars import PySeries @expr_dispatch diff --git a/py-polars/polars/series/list.py b/py-polars/polars/series/list.py index 22c697e265bd..53bcb22ce6f3 100644 --- a/py-polars/polars/series/list.py +++ b/py-polars/polars/series/list.py @@ -10,13 +10,13 @@ from datetime import date, datetime, time from polars import Expr, Series - from polars.polars import PySeries - from polars.type_aliases import ( + from polars._typing import ( IntoExpr, IntoExprColumn, NullBehavior, ToStructStrategy, ) + from polars.polars import PySeries @expr_dispatch diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index 614360a5c86a..b5484841ae00 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -119,10 +119,7 @@ from hvplot.plotting.core import hvPlotTabularPolars from polars import DataFrame, DataType, Expr - from polars._utils.various import ( - NoDefault, - ) - from polars.type_aliases import ( + from polars._typing import ( BufferInfo, ClosedInterval, ComparisonOperator, @@ -144,6 +141,9 @@ SizeUnit, TemporalLiteral, ) + from polars._utils.various import ( + NoDefault, + ) if sys.version_info >= (3, 11): from typing import Self diff --git a/py-polars/polars/series/string.py b/py-polars/polars/series/string.py index e14dbeb17225..c65f7dfb803b 100644 --- a/py-polars/polars/series/string.py +++ b/py-polars/polars/series/string.py @@ -8,8 +8,7 @@ if TYPE_CHECKING: from polars import Expr, Series - from polars.polars import PySeries - from polars.type_aliases import ( + from polars._typing import ( Ambiguous, IntoExpr, IntoExprColumn, @@ -18,6 +17,7 @@ TimeUnit, TransferEncoding, ) + from polars.polars import PySeries @expr_dispatch diff --git a/py-polars/polars/series/utils.py b/py-polars/polars/series/utils.py index 34b09fb3d0da..7668ad8143b1 100644 --- a/py-polars/polars/series/utils.py +++ b/py-polars/polars/series/utils.py @@ -12,8 +12,8 @@ if TYPE_CHECKING: from polars import Series + from polars._typing import PolarsDataType from polars.polars import PySeries - from polars.type_aliases import PolarsDataType if sys.version_info >= (3, 10): from typing import ParamSpec diff --git a/py-polars/polars/sql/context.py b/py-polars/polars/sql/context.py index bdac6c797e2a..0d207ac3a1fd 100644 --- a/py-polars/polars/sql/context.py +++ b/py-polars/polars/sql/context.py @@ -12,6 +12,7 @@ overload, ) +from polars._typing import FrameType from polars._utils.deprecation import deprecate_renamed_parameter from polars._utils.unstable import issue_unstable_warning from polars._utils.various import _get_stack_locals @@ -23,7 +24,6 @@ from polars.dependencies import pyarrow as pa from polars.lazyframe import LazyFrame from polars.series import Series -from polars.type_aliases import FrameType with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PySQLContext diff --git a/py-polars/polars/testing/parametric/profiles.py b/py-polars/polars/testing/parametric/profiles.py index 5cfe0bdde35e..e2be6e43ba3e 100644 --- a/py-polars/polars/testing/parametric/profiles.py +++ b/py-polars/polars/testing/parametric/profiles.py @@ -5,7 +5,7 @@ from hypothesis import settings -from polars.type_aliases import ParametricProfileNames +from polars._typing import ParametricProfileNames def load_profile( diff --git a/py-polars/polars/testing/parametric/strategies/core.py b/py-polars/polars/testing/parametric/strategies/core.py index fd15bd96fe77..483e06623437 100644 --- a/py-polars/polars/testing/parametric/strategies/core.py +++ b/py-polars/polars/testing/parametric/strategies/core.py @@ -21,7 +21,7 @@ from hypothesis.strategies import DrawFn, SearchStrategy from polars import LazyFrame - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType _ROW_LIMIT = 5 # max generated frame/series length diff --git a/py-polars/polars/testing/parametric/strategies/data.py b/py-polars/polars/testing/parametric/strategies/data.py index c42f073a24c3..adf94379326b 100644 --- a/py-polars/polars/testing/parametric/strategies/data.py +++ b/py-polars/polars/testing/parametric/strategies/data.py @@ -64,8 +64,8 @@ from hypothesis.strategies import SearchStrategy + from polars._typing import PolarsDataType, SchemaDict, TimeUnit from polars.datatypes import DataType, DataTypeClass - from polars.type_aliases import PolarsDataType, SchemaDict, TimeUnit _DEFAULT_LIST_LEN_LIMIT = 3 _DEFAULT_N_CATEGORIES = 10 diff --git a/py-polars/polars/testing/parametric/strategies/dtype.py b/py-polars/polars/testing/parametric/strategies/dtype.py index 3bd00bf87bcf..96dd928d2b84 100644 --- a/py-polars/polars/testing/parametric/strategies/dtype.py +++ b/py-polars/polars/testing/parametric/strategies/dtype.py @@ -37,8 +37,8 @@ if TYPE_CHECKING: from hypothesis.strategies import DrawFn, SearchStrategy + from polars._typing import CategoricalOrdering, PolarsDataType, TimeUnit from polars.datatypes import DataTypeClass - from polars.type_aliases import CategoricalOrdering, PolarsDataType, TimeUnit # Supported data type classes which do not take any arguments diff --git a/py-polars/polars/testing/parametric/strategies/legacy.py b/py-polars/polars/testing/parametric/strategies/legacy.py index bb3c59f6a9e5..7e238594a5c3 100644 --- a/py-polars/polars/testing/parametric/strategies/legacy.py +++ b/py-polars/polars/testing/parametric/strategies/legacy.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: from hypothesis.strategies import SearchStrategy - from polars.type_aliases import OneOrMoreDataTypes, PolarsDataType + from polars._typing import OneOrMoreDataTypes, PolarsDataType @deprecate_function( diff --git a/py-polars/tests/unit/constructors/test_any_value_fallbacks.py b/py-polars/tests/unit/constructors/test_any_value_fallbacks.py index c84b2c62825b..e9413edfb060 100644 --- a/py-polars/tests/unit/constructors/test_any_value_fallbacks.py +++ b/py-polars/tests/unit/constructors/test_any_value_fallbacks.py @@ -13,7 +13,7 @@ from polars.polars import PySeries if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/constructors/test_constructors.py b/py-polars/tests/unit/constructors/test_constructors.py index bd49c0009b6c..bf5f6cc0e256 100644 --- a/py-polars/tests/unit/constructors/test_constructors.py +++ b/py-polars/tests/unit/constructors/test_constructors.py @@ -24,7 +24,7 @@ from zoneinfo import ZoneInfo - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/constructors/test_series.py b/py-polars/tests/unit/constructors/test_series.py index e672ccbd1eb6..cfc0c76b6dc2 100644 --- a/py-polars/tests/unit/constructors/test_series.py +++ b/py-polars/tests/unit/constructors/test_series.py @@ -12,7 +12,7 @@ from polars.testing.asserts.series import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_series_mixed_dtypes_list() -> None: diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 9bd3a29ae385..e6e4c64a11c1 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -34,7 +34,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import JoinStrategy, UniqueKeepStrategy + from polars._typing import JoinStrategy, UniqueKeepStrategy else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/dataframe/test_serde.py b/py-polars/tests/unit/dataframe/test_serde.py index 19eafae6b5dc..b12cd393cb6f 100644 --- a/py-polars/tests/unit/dataframe/test_serde.py +++ b/py-polars/tests/unit/dataframe/test_serde.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import SerializationFormat + from polars._typing import SerializationFormat @given(df=dataframes()) diff --git a/py-polars/tests/unit/dataframe/test_upsample.py b/py-polars/tests/unit/dataframe/test_upsample.py index 161687c179bb..163245fb1502 100644 --- a/py-polars/tests/unit/dataframe/test_upsample.py +++ b/py-polars/tests/unit/dataframe/test_upsample.py @@ -14,7 +14,7 @@ from zoneinfo import ZoneInfo - from polars.type_aliases import FillNullStrategy, PolarsIntegerType + from polars._typing import FillNullStrategy, PolarsIntegerType else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/datatypes/test_categorical.py b/py-polars/tests/unit/datatypes/test_categorical.py index 916c9d7a0916..bd9f0524824d 100644 --- a/py-polars/tests/unit/datatypes/test_categorical.py +++ b/py-polars/tests/unit/datatypes/test_categorical.py @@ -17,7 +17,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @StringCache() diff --git a/py-polars/tests/unit/datatypes/test_list.py b/py-polars/tests/unit/datatypes/test_list.py index 091a949f63bc..5ff691d0fa51 100644 --- a/py-polars/tests/unit/datatypes/test_list.py +++ b/py-polars/tests/unit/datatypes/test_list.py @@ -13,7 +13,7 @@ from tests.unit.conftest import NUMERIC_DTYPES if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_dtype() -> None: diff --git a/py-polars/tests/unit/datatypes/test_parse.py b/py-polars/tests/unit/datatypes/test_parse.py index b448633fb92b..1eb4f6325525 100644 --- a/py-polars/tests/unit/datatypes/test_parse.py +++ b/py-polars/tests/unit/datatypes/test_parse.py @@ -25,7 +25,7 @@ ) if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def assert_dtype_equal(left: PolarsDataType, right: PolarsDataType) -> None: diff --git a/py-polars/tests/unit/datatypes/test_struct.py b/py-polars/tests/unit/datatypes/test_struct.py index 15276ef9ace0..418baef35529 100644 --- a/py-polars/tests/unit/datatypes/test_struct.py +++ b/py-polars/tests/unit/datatypes/test_struct.py @@ -13,7 +13,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_struct_to_list() -> None: diff --git a/py-polars/tests/unit/datatypes/test_temporal.py b/py-polars/tests/unit/datatypes/test_temporal.py index da2f19a2ce6b..b87f7b4bcaa0 100644 --- a/py-polars/tests/unit/datatypes/test_temporal.py +++ b/py-polars/tests/unit/datatypes/test_temporal.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import ( + from polars._typing import ( Ambiguous, PolarsTemporalType, TimeUnit, diff --git a/py-polars/tests/unit/expr/test_exprs.py b/py-polars/tests/unit/expr/test_exprs.py index 2561dcecb466..fc5d35c1d918 100644 --- a/py-polars/tests/unit/expr/test_exprs.py +++ b/py-polars/tests/unit/expr/test_exprs.py @@ -21,7 +21,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/functions/as_datatype/test_datetime.py b/py-polars/tests/unit/functions/as_datatype/test_datetime.py index 4970ea43b78b..62cc5fe09ff0 100644 --- a/py-polars/tests/unit/functions/as_datatype/test_datetime.py +++ b/py-polars/tests/unit/functions/as_datatype/test_datetime.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/functions/as_datatype/test_duration.py b/py-polars/tests/unit/functions/as_datatype/test_duration.py index 1a87f0da09a8..8bef49e1f074 100644 --- a/py-polars/tests/unit/functions/as_datatype/test_duration.py +++ b/py-polars/tests/unit/functions/as_datatype/test_duration.py @@ -9,7 +9,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit def test_empty_duration() -> None: diff --git a/py-polars/tests/unit/functions/range/test_date_range.py b/py-polars/tests/unit/functions/range/test_date_range.py index 6e9c888a6570..0c15adae778a 100644 --- a/py-polars/tests/unit/functions/range/test_date_range.py +++ b/py-polars/tests/unit/functions/range/test_date_range.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import ClosedInterval + from polars._typing import ClosedInterval def test_date_range() -> None: diff --git a/py-polars/tests/unit/functions/range/test_datetime_range.py b/py-polars/tests/unit/functions/range/test_datetime_range.py index 18d63801b323..22a57c567396 100644 --- a/py-polars/tests/unit/functions/range/test_datetime_range.py +++ b/py-polars/tests/unit/functions/range/test_datetime_range.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import ClosedInterval, PolarsDataType, TimeUnit + from polars._typing import ClosedInterval, PolarsDataType, TimeUnit else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/functions/range/test_time_range.py b/py-polars/tests/unit/functions/range/test_time_range.py index 9db8dcb66be1..63bf5e0ec73f 100644 --- a/py-polars/tests/unit/functions/range/test_time_range.py +++ b/py-polars/tests/unit/functions/range/test_time_range.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import ClosedInterval + from polars._typing import ClosedInterval def test_time_range_schema() -> None: diff --git a/py-polars/tests/unit/functions/test_functions.py b/py-polars/tests/unit/functions/test_functions.py index be4cfd4f8aa7..cb15656a19d4 100644 --- a/py-polars/tests/unit/functions/test_functions.py +++ b/py-polars/tests/unit/functions/test_functions.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import ConcatMethod + from polars._typing import ConcatMethod def test_concat_align() -> None: diff --git a/py-polars/tests/unit/functions/test_lit.py b/py-polars/tests/unit/functions/test_lit.py index ccb1bca4e109..4b8ca8abe796 100644 --- a/py-polars/tests/unit/functions/test_lit.py +++ b/py-polars/tests/unit/functions/test_lit.py @@ -15,7 +15,7 @@ from polars.testing.parametric.strategies.data import datetimes if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/functions/test_repeat.py b/py-polars/tests/unit/functions/test_repeat.py index 09a06386867f..94809d65e643 100644 --- a/py-polars/tests/unit/functions/test_repeat.py +++ b/py-polars/tests/unit/functions/test_repeat.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/interchange/test_roundtrip.py b/py-polars/tests/unit/interchange/test_roundtrip.py index 4ad62f6f2165..13ee04d5c37d 100644 --- a/py-polars/tests/unit/interchange/test_roundtrip.py +++ b/py-polars/tests/unit/interchange/test_roundtrip.py @@ -15,7 +15,7 @@ from polars.testing.parametric import dataframes if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType protocol_dtypes: list[PolarsDataType] = [ pl.Int8, diff --git a/py-polars/tests/unit/interchange/test_utils.py b/py-polars/tests/unit/interchange/test_utils.py index e3be2d69feff..527de10ffc1e 100644 --- a/py-polars/tests/unit/interchange/test_utils.py +++ b/py-polars/tests/unit/interchange/test_utils.py @@ -14,8 +14,8 @@ ) if TYPE_CHECKING: + from polars._typing import PolarsDataType from polars.interchange.protocol import Dtype - from polars.type_aliases import PolarsDataType NE = Endianness.NATIVE diff --git a/py-polars/tests/unit/interop/numpy/test_from_numpy_df.py b/py-polars/tests/unit/interop/numpy/test_from_numpy_df.py index 5577525c4a83..0843ded62b27 100644 --- a/py-polars/tests/unit/interop/numpy/test_from_numpy_df.py +++ b/py-polars/tests/unit/interop/numpy/test_from_numpy_df.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsTemporalType + from polars._typing import PolarsTemporalType def test_from_numpy() -> None: diff --git a/py-polars/tests/unit/interop/numpy/test_from_numpy_series.py b/py-polars/tests/unit/interop/numpy/test_from_numpy_series.py index 67a9088c36b7..4c7f3d8c14d2 100644 --- a/py-polars/tests/unit/interop/numpy/test_from_numpy_series.py +++ b/py-polars/tests/unit/interop/numpy/test_from_numpy_series.py @@ -9,7 +9,7 @@ import polars as pl if TYPE_CHECKING: - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit @pytest.mark.parametrize("time_unit", ["ms", "us", "ns"]) diff --git a/py-polars/tests/unit/interop/numpy/test_to_numpy_df.py b/py-polars/tests/unit/interop/numpy/test_to_numpy_df.py index 2aae6db17d71..c25a544d4d9d 100644 --- a/py-polars/tests/unit/interop/numpy/test_to_numpy_df.py +++ b/py-polars/tests/unit/interop/numpy/test_to_numpy_df.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: import numpy.typing as npt - from polars.type_aliases import IndexOrder, PolarsDataType + from polars._typing import IndexOrder, PolarsDataType def assert_zero_copy(s: pl.Series, arr: np.ndarray[Any, Any]) -> None: diff --git a/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py b/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py index c0f7ac03b956..8ac2e2f73321 100644 --- a/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py +++ b/py-polars/tests/unit/interop/numpy/test_to_numpy_series.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: import numpy.typing as npt - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def assert_zero_copy(s: pl.Series, arr: np.ndarray[Any, Any]) -> None: diff --git a/py-polars/tests/unit/interop/test_interop.py b/py-polars/tests/unit/interop/test_interop.py index e9ce233c696e..2802023e8b9c 100644 --- a/py-polars/tests/unit/interop/test_interop.py +++ b/py-polars/tests/unit/interop/test_interop.py @@ -13,7 +13,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_from_pandas() -> None: diff --git a/py-polars/tests/unit/interop/test_to_pandas.py b/py-polars/tests/unit/interop/test_to_pandas.py index b43f9de08780..b00d6c59de58 100644 --- a/py-polars/tests/unit/interop/test_to_pandas.py +++ b/py-polars/tests/unit/interop/test_to_pandas.py @@ -13,7 +13,7 @@ import polars as pl if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_df_to_pandas_empty() -> None: diff --git a/py-polars/tests/unit/io/database/test_inference.py b/py-polars/tests/unit/io/database/test_inference.py index 1a4e2277ee65..d4140a576f4c 100644 --- a/py-polars/tests/unit/io/database/test_inference.py +++ b/py-polars/tests/unit/io/database/test_inference.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/io/database/test_read.py b/py-polars/tests/unit/io/database/test_read.py index 3e94bb567183..ab42f7993fea 100644 --- a/py-polars/tests/unit/io/database/test_read.py +++ b/py-polars/tests/unit/io/database/test_read.py @@ -21,7 +21,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import ( + from polars._typing import ( ConnectionOrCursor, DbReadEngine, SchemaDefinition, diff --git a/py-polars/tests/unit/io/database/test_write.py b/py-polars/tests/unit/io/database/test_write.py index 4addd16186ac..435bbdc78d8c 100644 --- a/py-polars/tests/unit/io/database/test_write.py +++ b/py-polars/tests/unit/io/database/test_write.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import DbWriteEngine + from polars._typing import DbWriteEngine @pytest.mark.write_disk() diff --git a/py-polars/tests/unit/io/test_avro.py b/py-polars/tests/unit/io/test_avro.py index d8856d6dc5c8..8a622f041c6e 100644 --- a/py-polars/tests/unit/io/test_avro.py +++ b/py-polars/tests/unit/io/test_avro.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import AvroCompression + from polars._typing import AvroCompression COMPRESSIONS = ["uncompressed", "snappy", "deflate"] diff --git a/py-polars/tests/unit/io/test_csv.py b/py-polars/tests/unit/io/test_csv.py index 8c61e1981b43..113d0cedc89c 100644 --- a/py-polars/tests/unit/io/test_csv.py +++ b/py-polars/tests/unit/io/test_csv.py @@ -25,7 +25,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit from tests.unit.conftest import MemoryUsage diff --git a/py-polars/tests/unit/io/test_ipc.py b/py-polars/tests/unit/io/test_ipc.py index 9350d21da036..278cc8192e4a 100644 --- a/py-polars/tests/unit/io/test_ipc.py +++ b/py-polars/tests/unit/io/test_ipc.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import IpcCompression + from polars._typing import IpcCompression from tests.unit.conftest import MemoryUsage COMPRESSIONS = ["uncompressed", "lz4", "zstd"] diff --git a/py-polars/tests/unit/io/test_lazy_parquet.py b/py-polars/tests/unit/io/test_lazy_parquet.py index 3e65ea6b0451..b9ba7d258515 100644 --- a/py-polars/tests/unit/io/test_lazy_parquet.py +++ b/py-polars/tests/unit/io/test_lazy_parquet.py @@ -12,7 +12,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import ParallelStrategy + from polars._typing import ParallelStrategy @pytest.fixture() diff --git a/py-polars/tests/unit/io/test_parquet.py b/py-polars/tests/unit/io/test_parquet.py index a14472f2edb9..173cf84d56fd 100644 --- a/py-polars/tests/unit/io/test_parquet.py +++ b/py-polars/tests/unit/io/test_parquet.py @@ -24,7 +24,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import ParquetCompression + from polars._typing import ParquetCompression from tests.unit.conftest import MemoryUsage diff --git a/py-polars/tests/unit/io/test_scan.py b/py-polars/tests/unit/io/test_scan.py index e3966a2ca8d1..0560985a1609 100644 --- a/py-polars/tests/unit/io/test_scan.py +++ b/py-polars/tests/unit/io/test_scan.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import SchemaDict + from polars._typing import SchemaDict @dataclass diff --git a/py-polars/tests/unit/io/test_spreadsheet.py b/py-polars/tests/unit/io/test_spreadsheet.py index 180d23c33216..04a784ada902 100644 --- a/py-polars/tests/unit/io/test_spreadsheet.py +++ b/py-polars/tests/unit/io/test_spreadsheet.py @@ -17,7 +17,7 @@ from tests.unit.conftest import FLOAT_DTYPES, NUMERIC_DTYPES if TYPE_CHECKING: - from polars.type_aliases import ExcelSpreadsheetEngine, SchemaDict, SelectorType + from polars._typing import ExcelSpreadsheetEngine, SchemaDict, SelectorType pytestmark = pytest.mark.slow() diff --git a/py-polars/tests/unit/lazyframe/test_lazyframe.py b/py-polars/tests/unit/lazyframe/test_lazyframe.py index f4fb1a11403a..78cc18898068 100644 --- a/py-polars/tests/unit/lazyframe/test_lazyframe.py +++ b/py-polars/tests/unit/lazyframe/test_lazyframe.py @@ -24,7 +24,7 @@ if TYPE_CHECKING: from _pytest.capture import CaptureFixture - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_init_signature_match() -> None: diff --git a/py-polars/tests/unit/lazyframe/test_serde.py b/py-polars/tests/unit/lazyframe/test_serde.py index 03dd86369f46..941cf6996cd3 100644 --- a/py-polars/tests/unit/lazyframe/test_serde.py +++ b/py-polars/tests/unit/lazyframe/test_serde.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import SerializationFormat + from polars._typing import SerializationFormat @given(lf=dataframes(lazy=True)) diff --git a/py-polars/tests/unit/ml/test_to_jax.py b/py-polars/tests/unit/ml/test_to_jax.py index 07b2ee840acf..e18902a11348 100644 --- a/py-polars/tests/unit/ml/test_to_jax.py +++ b/py-polars/tests/unit/ml/test_to_jax.py @@ -17,7 +17,7 @@ pytestmark = pytest.mark.ci_only if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.fixture() diff --git a/py-polars/tests/unit/operations/aggregation/test_aggregations.py b/py-polars/tests/unit/operations/aggregation/test_aggregations.py index 8301dfb0ee1b..ff6b27280382 100644 --- a/py-polars/tests/unit/operations/aggregation/test_aggregations.py +++ b/py-polars/tests/unit/operations/aggregation/test_aggregations.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: import numpy.typing as npt - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_quantile_expr_input() -> None: diff --git a/py-polars/tests/unit/operations/aggregation/test_horizontal.py b/py-polars/tests/unit/operations/aggregation/test_horizontal.py index b6e5d3f8214a..bc2bf2abbf46 100644 --- a/py-polars/tests/unit/operations/aggregation/test_horizontal.py +++ b/py-polars/tests/unit/operations/aggregation/test_horizontal.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_any_expr(fruits_cars: pl.DataFrame) -> None: diff --git a/py-polars/tests/unit/operations/arithmetic/test_neg.py b/py-polars/tests/unit/operations/arithmetic/test_neg.py index 598e2dcebb8f..90b0cac2795b 100644 --- a/py-polars/tests/unit/operations/arithmetic/test_neg.py +++ b/py-polars/tests/unit/operations/arithmetic/test_neg.py @@ -12,7 +12,7 @@ from polars.testing.asserts.series import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_add_business_days.py b/py-polars/tests/unit/operations/namespaces/temporal/test_add_business_days.py index e6aa320dcbd5..5fe78225670e 100644 --- a/py-polars/tests/unit/operations/namespaces/temporal/test_add_business_days.py +++ b/py-polars/tests/unit/operations/namespaces/temporal/test_add_business_days.py @@ -16,7 +16,7 @@ from polars.testing import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import Roll, TimeUnit + from polars._typing import Roll, TimeUnit if sys.version_info >= (3, 9): from zoneinfo import ZoneInfo diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py b/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py index c97b055eb2ba..38f47b6b2b43 100644 --- a/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py +++ b/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import TemporalLiteral, TimeUnit + from polars._typing import TemporalLiteral, TimeUnit else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_offset_by.py b/py-polars/tests/unit/operations/namespaces/temporal/test_offset_by.py index 072faa175c8a..79adde1e7b81 100644 --- a/py-polars/tests/unit/operations/namespaces/temporal/test_offset_by.py +++ b/py-polars/tests/unit/operations/namespaces/temporal/test_offset_by.py @@ -9,7 +9,7 @@ from polars.testing import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_to_datetime.py b/py-polars/tests/unit/operations/namespaces/temporal/test_to_datetime.py index 07a38b4ad608..12f4c94b1cc6 100644 --- a/py-polars/tests/unit/operations/namespaces/temporal/test_to_datetime.py +++ b/py-polars/tests/unit/operations/namespaces/temporal/test_to_datetime.py @@ -23,7 +23,7 @@ if TYPE_CHECKING: from hypothesis.strategies import DrawFn - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit DATE_FORMATS = ["%Y{}%m{}%d", "%d{}%m{}%Y"] diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_truncate.py b/py-polars/tests/unit/operations/namespaces/temporal/test_truncate.py index 03e19b453048..b679d3859a4c 100644 --- a/py-polars/tests/unit/operations/namespaces/temporal/test_truncate.py +++ b/py-polars/tests/unit/operations/namespaces/temporal/test_truncate.py @@ -11,7 +11,7 @@ from polars.testing import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit @given( diff --git a/py-polars/tests/unit/operations/namespaces/test_binary.py b/py-polars/tests/unit/operations/namespaces/test_binary.py index 7e5a05438858..1bde83cb0547 100644 --- a/py-polars/tests/unit/operations/namespaces/test_binary.py +++ b/py-polars/tests/unit/operations/namespaces/test_binary.py @@ -1,8 +1,8 @@ import pytest import polars as pl +from polars._typing import TransferEncoding from polars.testing import assert_frame_equal -from polars.type_aliases import TransferEncoding def test_binary_conversions() -> None: diff --git a/py-polars/tests/unit/operations/namespaces/test_strptime.py b/py-polars/tests/unit/operations/namespaces/test_strptime.py index 7f2e92a3d280..3aa5890198df 100644 --- a/py-polars/tests/unit/operations/namespaces/test_strptime.py +++ b/py-polars/tests/unit/operations/namespaces/test_strptime.py @@ -18,7 +18,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import PolarsTemporalType, TimeUnit + from polars._typing import PolarsTemporalType, TimeUnit else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/operations/rolling/test_map.py b/py-polars/tests/unit/operations/rolling/test_map.py index 4e192768b3d0..730b76baad55 100644 --- a/py-polars/tests/unit/operations/rolling/test_map.py +++ b/py-polars/tests/unit/operations/rolling/test_map.py @@ -9,7 +9,7 @@ from polars.testing import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/operations/rolling/test_rolling.py b/py-polars/tests/unit/operations/rolling/test_rolling.py index 0ae7cb575441..99451f309137 100644 --- a/py-polars/tests/unit/operations/rolling/test_rolling.py +++ b/py-polars/tests/unit/operations/rolling/test_rolling.py @@ -19,7 +19,7 @@ if TYPE_CHECKING: from hypothesis.strategies import SearchStrategy - from polars.type_aliases import ClosedInterval, PolarsDataType, TimeUnit + from polars._typing import ClosedInterval, PolarsDataType, TimeUnit @pytest.fixture() diff --git a/py-polars/tests/unit/operations/test_abs.py b/py-polars/tests/unit/operations/test_abs.py index 08b9d4a11a7f..68e4518a93f9 100644 --- a/py-polars/tests/unit/operations/test_abs.py +++ b/py-polars/tests/unit/operations/test_abs.py @@ -12,7 +12,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_abs() -> None: diff --git a/py-polars/tests/unit/operations/test_cast.py b/py-polars/tests/unit/operations/test_cast.py index ae6c498fc71a..1b00c4fb0fe3 100644 --- a/py-polars/tests/unit/operations/test_cast.py +++ b/py-polars/tests/unit/operations/test_cast.py @@ -13,7 +13,7 @@ from polars.testing.asserts.series import assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_string_date() -> None: diff --git a/py-polars/tests/unit/operations/test_comparison.py b/py-polars/tests/unit/operations/test_comparison.py index 39206ce6b270..eb74f374f6a1 100644 --- a/py-polars/tests/unit/operations/test_comparison.py +++ b/py-polars/tests/unit/operations/test_comparison.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_comparison_order_null_broadcasting() -> None: diff --git a/py-polars/tests/unit/operations/test_ewm_by.py b/py-polars/tests/unit/operations/test_ewm_by.py index 9ff87c9bbd29..e804f6b6d5d8 100644 --- a/py-polars/tests/unit/operations/test_ewm_by.py +++ b/py-polars/tests/unit/operations/test_ewm_by.py @@ -12,7 +12,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsIntegerType, TimeUnit + from polars._typing import PolarsIntegerType, TimeUnit if sys.version_info >= (3, 9): from zoneinfo import ZoneInfo diff --git a/py-polars/tests/unit/operations/test_extend_constant.py b/py-polars/tests/unit/operations/test_extend_constant.py index f47452313553..2106b0dfec83 100644 --- a/py-polars/tests/unit/operations/test_extend_constant.py +++ b/py-polars/tests/unit/operations/test_extend_constant.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/operations/test_filter.py b/py-polars/tests/unit/operations/test_filter.py index d1c0de20a04b..df796b44b991 100644 --- a/py-polars/tests/unit/operations/test_filter.py +++ b/py-polars/tests/unit/operations/test_filter.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_simplify_expression_lit_true_4376() -> None: diff --git a/py-polars/tests/unit/operations/test_group_by.py b/py-polars/tests/unit/operations/test_group_by.py index 1c7ccd4d2396..c2234035ffdb 100644 --- a/py-polars/tests/unit/operations/test_group_by.py +++ b/py-polars/tests/unit/operations/test_group_by.py @@ -13,7 +13,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_group_by() -> None: diff --git a/py-polars/tests/unit/operations/test_group_by_dynamic.py b/py-polars/tests/unit/operations/test_group_by_dynamic.py index 84bf7062339e..0c083e204725 100644 --- a/py-polars/tests/unit/operations/test_group_by_dynamic.py +++ b/py-polars/tests/unit/operations/test_group_by_dynamic.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import Label, StartBy + from polars._typing import Label, StartBy else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/operations/test_interpolate.py b/py-polars/tests/unit/operations/test_interpolate.py index c4223b7480ed..e80d4102466c 100644 --- a/py-polars/tests/unit/operations/test_interpolate.py +++ b/py-polars/tests/unit/operations/test_interpolate.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType, PolarsTemporalType + from polars._typing import PolarsDataType, PolarsTemporalType if sys.version_info >= (3, 9): from zoneinfo import ZoneInfo diff --git a/py-polars/tests/unit/operations/test_interpolate_by.py b/py-polars/tests/unit/operations/test_interpolate_by.py index 24948a47b2ac..423992abeadd 100644 --- a/py-polars/tests/unit/operations/test_interpolate_by.py +++ b/py-polars/tests/unit/operations/test_interpolate_by.py @@ -14,7 +14,7 @@ from polars.testing.parametric import column, dataframes if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/operations/test_is_first_last_distinct.py b/py-polars/tests/unit/operations/test_is_first_last_distinct.py index ec07ef4c8b03..00a6e0a5f259 100644 --- a/py-polars/tests/unit/operations/test_is_first_last_distinct.py +++ b/py-polars/tests/unit/operations/test_is_first_last_distinct.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_is_first_distinct() -> None: diff --git a/py-polars/tests/unit/operations/test_is_in.py b/py-polars/tests/unit/operations/test_is_in.py index afb3f83d619a..8f6e5f7bc8e2 100644 --- a/py-polars/tests/unit/operations/test_is_in.py +++ b/py-polars/tests/unit/operations/test_is_in.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_struct_logical_is_in() -> None: diff --git a/py-polars/tests/unit/operations/test_join.py b/py-polars/tests/unit/operations/test_join.py index d2e1db858757..797f9b750cc5 100644 --- a/py-polars/tests/unit/operations/test_join.py +++ b/py-polars/tests/unit/operations/test_join.py @@ -18,7 +18,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import JoinStrategy + from polars._typing import JoinStrategy def test_semi_anti_join() -> None: diff --git a/py-polars/tests/unit/operations/test_pivot.py b/py-polars/tests/unit/operations/test_pivot.py index dced58df5618..c9812fd7e1bd 100644 --- a/py-polars/tests/unit/operations/test_pivot.py +++ b/py-polars/tests/unit/operations/test_pivot.py @@ -11,7 +11,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import PivotAgg + from polars._typing import PivotAgg def test_pivot() -> None: diff --git a/py-polars/tests/unit/operations/test_rolling.py b/py-polars/tests/unit/operations/test_rolling.py index 420da32725b8..b67cb441bc56 100644 --- a/py-polars/tests/unit/operations/test_rolling.py +++ b/py-polars/tests/unit/operations/test_rolling.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import ClosedInterval, PolarsIntegerType + from polars._typing import ClosedInterval, PolarsIntegerType def test_rolling() -> None: diff --git a/py-polars/tests/unit/operations/test_sort.py b/py-polars/tests/unit/operations/test_sort.py index 8f0c490840e7..c0bf04e5a4dc 100644 --- a/py-polars/tests/unit/operations/test_sort.py +++ b/py-polars/tests/unit/operations/test_sort.py @@ -11,7 +11,7 @@ from polars.testing.parametric import dataframes, series if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @given( diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index e28009651b40..0eef7af263b1 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -33,7 +33,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import EpochTimeUnit, PolarsDataType, TimeUnit + from polars._typing import EpochTimeUnit, PolarsDataType, TimeUnit else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo diff --git a/py-polars/tests/unit/sql/test_numeric.py b/py-polars/tests/unit/sql/test_numeric.py index 5ab41741e486..fed1d97a948e 100644 --- a/py-polars/tests/unit/sql/test_numeric.py +++ b/py-polars/tests/unit/sql/test_numeric.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal, assert_series_equal if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType def test_div() -> None: diff --git a/py-polars/tests/unit/streaming/test_streaming.py b/py-polars/tests/unit/streaming/test_streaming.py index 14b927082a19..2ca3aa772365 100644 --- a/py-polars/tests/unit/streaming/test_streaming.py +++ b/py-polars/tests/unit/streaming/test_streaming.py @@ -14,7 +14,7 @@ from polars.testing import assert_frame_equal if TYPE_CHECKING: - from polars.type_aliases import JoinStrategy + from polars._typing import JoinStrategy pytestmark = pytest.mark.xdist_group("streaming") diff --git a/py-polars/tests/unit/streaming/test_streaming_join.py b/py-polars/tests/unit/streaming/test_streaming_join.py index ccbbc2b08f73..f83695a8db7e 100644 --- a/py-polars/tests/unit/streaming/test_streaming_join.py +++ b/py-polars/tests/unit/streaming/test_streaming_join.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from pathlib import Path - from polars.type_aliases import JoinStrategy + from polars._typing import JoinStrategy pytestmark = pytest.mark.xdist_group("streaming") diff --git a/py-polars/tests/unit/test_datatypes.py b/py-polars/tests/unit/test_datatypes.py index 89a8ff4079c6..8313c4203c1f 100644 --- a/py-polars/tests/unit/test_datatypes.py +++ b/py-polars/tests/unit/test_datatypes.py @@ -20,8 +20,8 @@ from tests.unit.conftest import DATETIME_DTYPES, NUMERIC_DTYPES if TYPE_CHECKING: + from polars._typing import PolarsDataType from polars.datatypes.classes import DataTypeClass - from polars.type_aliases import PolarsDataType SIMPLE_DTYPES: list[DataTypeClass] = [ *[dt.base_type() for dt in NUMERIC_DTYPES], diff --git a/py-polars/tests/unit/test_errors.py b/py-polars/tests/unit/test_errors.py index ad8152b24a7f..7006cd36ad48 100644 --- a/py-polars/tests/unit/test_errors.py +++ b/py-polars/tests/unit/test_errors.py @@ -24,7 +24,7 @@ from tests.unit.conftest import TEMPORAL_DTYPES if TYPE_CHECKING: - from polars.type_aliases import ConcatMethod + from polars._typing import ConcatMethod def test_error_on_empty_group_by() -> None: diff --git a/py-polars/tests/unit/test_format.py b/py-polars/tests/unit/test_format.py index cba8f2193438..8f69d62fcaee 100644 --- a/py-polars/tests/unit/test_format.py +++ b/py-polars/tests/unit/test_format.py @@ -10,7 +10,7 @@ from polars.exceptions import InvalidOperationError if TYPE_CHECKING: - from polars.type_aliases import PolarsDataType + from polars._typing import PolarsDataType @pytest.fixture(autouse=True) diff --git a/py-polars/tests/unit/test_selectors.py b/py-polars/tests/unit/test_selectors.py index 6657dd051d0a..0bcb839bec62 100644 --- a/py-polars/tests/unit/test_selectors.py +++ b/py-polars/tests/unit/test_selectors.py @@ -7,11 +7,11 @@ import polars as pl import polars.selectors as cs +from polars._typing import SelectorType from polars.dependencies import _ZONEINFO_AVAILABLE from polars.exceptions import ColumnNotFoundError from polars.selectors import expand_selector, is_selector from polars.testing import assert_frame_equal -from polars.type_aliases import SelectorType from tests.unit.conftest import INTEGER_DTYPES, TEMPORAL_DTYPES if sys.version_info >= (3, 9): diff --git a/py-polars/tests/unit/utils/test_utils.py b/py-polars/tests/unit/utils/test_utils.py index 194070822be3..603d0a2e959a 100644 --- a/py-polars/tests/unit/utils/test_utils.py +++ b/py-polars/tests/unit/utils/test_utils.py @@ -27,7 +27,7 @@ if TYPE_CHECKING: from zoneinfo import ZoneInfo - from polars.type_aliases import TimeUnit + from polars._typing import TimeUnit else: from polars._utils.convert import string_to_zoneinfo as ZoneInfo From cc2cca93c93d73e213676c3148e08f2a40685616 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 29 Jun 2024 01:16:26 +0200 Subject: [PATCH 2/2] Add deprecation for old module --- py-polars/polars/type_aliases.py | 25 +++++++++++++++++++++++++ py-polars/tests/unit/test_init.py | 8 ++++++++ 2 files changed, 33 insertions(+) create mode 100644 py-polars/polars/type_aliases.py diff --git a/py-polars/polars/type_aliases.py b/py-polars/polars/type_aliases.py new file mode 100644 index 000000000000..555887c91edb --- /dev/null +++ b/py-polars/polars/type_aliases.py @@ -0,0 +1,25 @@ +""" +Deprecated module - do not use. + +Used to contain private type aliases. These are now in the `polars._typing` module. +""" + +from typing import Any + +import polars._typing as plt +from polars._utils.deprecation import issue_deprecation_warning + + +def __getattr__(name: str) -> Any: + if name in dir(plt): + issue_deprecation_warning( + "The `polars.type_aliases` module is deprecated." + " The type aliases have moved to the `polars._typing` module to explicitly mark them as private." + " Please define your own type aliases, or temporarily import from the `polars._typing` module." + " A public `polars.typing` module will be added in the future.", + version="1.0.0", + ) + return getattr(plt, name) + + msg = f"module {__name__!r} has no attribute {name!r}" + raise AttributeError(msg) diff --git a/py-polars/tests/unit/test_init.py b/py-polars/tests/unit/test_init.py index cf3dda945bb2..6222ae45fd8b 100644 --- a/py-polars/tests/unit/test_init.py +++ b/py-polars/tests/unit/test_init.py @@ -27,3 +27,11 @@ def test_dtype_groups_deprecated() -> None: dtypes = pl.INTEGER_DTYPES assert pl.Int8 in dtypes + + +def test_type_aliases_deprecated() -> None: + with pytest.deprecated_call( + match="The `polars.type_aliases` module is deprecated." + ): + from polars.type_aliases import PolarsDataType + assert str(PolarsDataType).startswith("typing.Union")