From 114235663449b991be9a27119bec8654a9ba091f Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 29 Feb 2024 14:06:52 +0100 Subject: [PATCH 1/5] Rename utils to _utils --- py-polars/polars/__init__.py | 8 +- .../polars/{utils => _utils}/__init__.py | 6 +- py-polars/polars/{utils => _utils}/_async.py | 2 +- .../polars/{utils => _utils}/_construction.py | 16 ++-- .../{utils => _utils}/_parse_expr_input.py | 2 +- .../{utils => _utils}/_polars_version.py | 0 py-polars/polars/{utils => _utils}/_scan.py | 0 py-polars/polars/{utils => _utils}/_wrap.py | 0 py-polars/polars/{utils => _utils}/convert.py | 0 .../polars/{utils => _utils}/deprecation.py | 2 +- py-polars/polars/{utils => _utils}/udfs.py | 6 +- .../polars/{utils => _utils}/unstable.py | 2 +- py-polars/polars/{utils => _utils}/various.py | 2 +- py-polars/polars/api.py | 2 +- py-polars/polars/config.py | 4 +- py-polars/polars/convert.py | 2 +- py-polars/polars/dataframe/frame.py | 74 +++++++++--------- py-polars/polars/dataframe/group_by.py | 4 +- py-polars/polars/datatypes/classes.py | 8 +- py-polars/polars/datatypes/convert.py | 2 +- py-polars/polars/dependencies.py | 2 +- py-polars/polars/expr/array.py | 4 +- py-polars/polars/expr/binary.py | 4 +- py-polars/polars/expr/categorical.py | 4 +- py-polars/polars/expr/datetime.py | 12 +-- py-polars/polars/expr/expr.py | 54 ++++++------- py-polars/polars/expr/list.py | 6 +- py-polars/polars/expr/meta.py | 8 +- py-polars/polars/expr/string.py | 14 ++-- py-polars/polars/expr/struct.py | 2 +- py-polars/polars/expr/whenthen.py | 6 +- .../functions/aggregation/horizontal.py | 6 +- .../polars/functions/aggregation/vertical.py | 2 +- py-polars/polars/functions/as_datatype.py | 8 +- py-polars/polars/functions/col.py | 2 +- py-polars/polars/functions/eager.py | 4 +- py-polars/polars/functions/lazy.py | 12 +-- py-polars/polars/functions/len.py | 2 +- py-polars/polars/functions/lit.py | 10 +-- py-polars/polars/functions/range/_utils.py | 2 +- .../polars/functions/range/date_range.py | 8 +- .../polars/functions/range/datetime_range.py | 6 +- py-polars/polars/functions/range/int_range.py | 4 +- .../polars/functions/range/time_range.py | 6 +- py-polars/polars/functions/repeat.py | 4 +- py-polars/polars/functions/whenthen.py | 2 +- py-polars/polars/io/_utils.py | 2 +- py-polars/polars/io/csv/batched_reader.py | 8 +- py-polars/polars/io/csv/functions.py | 4 +- py-polars/polars/io/database.py | 2 +- py-polars/polars/io/iceberg.py | 2 +- py-polars/polars/io/ipc/functions.py | 4 +- py-polars/polars/io/ndjson.py | 2 +- py-polars/polars/io/parquet/functions.py | 4 +- .../io/pyarrow_dataset/anonymous_scan.py | 4 +- .../polars/io/pyarrow_dataset/functions.py | 2 +- py-polars/polars/io/spreadsheet/functions.py | 4 +- py-polars/polars/lazyframe/frame.py | 50 ++++++------ py-polars/polars/lazyframe/group_by.py | 6 +- py-polars/polars/lazyframe/in_process.py | 2 +- py-polars/polars/meta/build.py | 2 +- py-polars/polars/meta/thread_pool.py | 2 +- py-polars/polars/meta/versions.py | 2 +- py-polars/polars/selectors.py | 6 +- py-polars/polars/series/array.py | 2 +- py-polars/polars/series/categorical.py | 6 +- py-polars/polars/series/datetime.py | 8 +- py-polars/polars/series/list.py | 6 +- py-polars/polars/series/series.py | 78 +++++++++---------- py-polars/polars/series/string.py | 6 +- py-polars/polars/series/struct.py | 4 +- py-polars/polars/series/utils.py | 2 +- py-polars/polars/sql/context.py | 6 +- py-polars/polars/string_cache.py | 2 +- .../polars/testing/parametric/profiles.py | 2 +- .../tests/parametric/test_groupby_rolling.py | 2 +- .../constructors/test_any_value_fallbacks.py | 2 +- .../unit/constructors/test_constructors.py | 4 +- py-polars/tests/unit/dataframe/test_df.py | 2 +- py-polars/tests/unit/io/test_csv.py | 2 +- .../map/test_inefficient_map_warning.py | 4 +- py-polars/tests/unit/operations/test_cast.py | 6 +- py-polars/tests/unit/series/test_series.py | 2 +- py-polars/tests/unit/test_config.py | 2 +- .../tests/unit/utils/test_deprecation.py | 2 +- .../tests/unit/utils/test_parse_expr_input.py | 4 +- py-polars/tests/unit/utils/test_unstable.py | 2 +- py-polars/tests/unit/utils/test_utils.py | 6 +- 88 files changed, 303 insertions(+), 303 deletions(-) rename py-polars/polars/{utils => _utils}/__init__.py (78%) rename py-polars/polars/{utils => _utils}/_async.py (98%) rename py-polars/polars/{utils => _utils}/_construction.py (99%) rename py-polars/polars/{utils => _utils}/_parse_expr_input.py (98%) rename py-polars/polars/{utils => _utils}/_polars_version.py (100%) rename py-polars/polars/{utils => _utils}/_scan.py (100%) rename py-polars/polars/{utils => _utils}/_wrap.py (100%) rename py-polars/polars/{utils => _utils}/convert.py (100%) rename py-polars/polars/{utils => _utils}/deprecation.py (99%) rename py-polars/polars/{utils => _utils}/udfs.py (99%) rename py-polars/polars/{utils => _utils}/unstable.py (97%) rename py-polars/polars/{utils => _utils}/various.py (99%) diff --git a/py-polars/polars/__init__.py b/py-polars/polars/__init__.py index d7f093484221..eb405fd370cb 100644 --- a/py-polars/polars/__init__.py +++ b/py-polars/polars/__init__.py @@ -18,6 +18,10 @@ __register_startup_deps() from polars import api +from polars._utils._polars_version import get_polars_version as _get_polars_version + +# TODO: remove need for importing wrap utils at top level +from polars._utils._wrap import wrap_df, wrap_s # noqa: F401 from polars.config import Config from polars.convert import ( from_arrow, @@ -214,10 +218,6 @@ using_string_cache, ) from polars.type_aliases import PolarsDataType -from polars.utils._polars_version import get_polars_version as _get_polars_version - -# TODO: remove need for importing wrap utils at top level -from polars.utils._wrap import wrap_df, wrap_s # noqa: F401 __version__: str = _get_polars_version() del _get_polars_version diff --git a/py-polars/polars/utils/__init__.py b/py-polars/polars/_utils/__init__.py similarity index 78% rename from py-polars/polars/utils/__init__.py rename to py-polars/polars/_utils/__init__.py index db6c1085bc14..487583f45660 100644 --- a/py-polars/polars/utils/__init__.py +++ b/py-polars/polars/_utils/__init__.py @@ -3,8 +3,8 @@ Functions that are part of the public API are re-exported here. """ -from polars.utils._scan import _execute_from_rust -from polars.utils.convert import ( +from polars._utils._scan import _execute_from_rust +from polars._utils.convert import ( date_to_int, datetime_to_int, time_to_int, @@ -15,7 +15,7 @@ to_py_time, to_py_timedelta, ) -from polars.utils.various import NoDefault, _polars_warn, is_column, no_default +from polars._utils.various import NoDefault, _polars_warn, is_column, no_default __all__ = [ "NoDefault", diff --git a/py-polars/polars/utils/_async.py b/py-polars/polars/_utils/_async.py similarity index 98% rename from py-polars/polars/utils/_async.py rename to py-polars/polars/_utils/_async.py index 60104271712e..9c90a5758d38 100644 --- a/py-polars/polars/utils/_async.py +++ b/py-polars/polars/_utils/_async.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING, Any, Awaitable, Generator, Generic, TypeVar +from polars._utils._wrap import wrap_df from polars.dependencies import _GEVENT_AVAILABLE -from polars.utils._wrap import wrap_df if TYPE_CHECKING: from asyncio.futures import Future diff --git a/py-polars/polars/utils/_construction.py b/py-polars/polars/_utils/_construction.py similarity index 99% rename from py-polars/polars/utils/_construction.py rename to py-polars/polars/_utils/_construction.py index daefe7b5b1e9..f99e88a9b7ba 100644 --- a/py-polars/polars/utils/_construction.py +++ b/py-polars/polars/_utils/_construction.py @@ -23,6 +23,14 @@ import polars._reexport as pl from polars import functions as F +from polars._utils._wrap import wrap_df, wrap_s +from polars._utils.various import ( + _is_generator, + arrlen, + find_stacklevel, + parse_version, + range_to_series, +) from polars.datatypes import ( INTEGER_DTYPES, N_INFER_DEFAULT, @@ -70,14 +78,6 @@ TimeZoneAwareConstructorWarning, ) from polars.meta import get_index_type, thread_pool_size -from polars.utils._wrap import wrap_df, wrap_s -from polars.utils.various import ( - _is_generator, - arrlen, - find_stacklevel, - parse_version, - range_to_series, -) with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PyDataFrame, PySeries diff --git a/py-polars/polars/utils/_parse_expr_input.py b/py-polars/polars/_utils/_parse_expr_input.py similarity index 98% rename from py-polars/polars/utils/_parse_expr_input.py rename to py-polars/polars/_utils/_parse_expr_input.py index 05970f11b367..1aa72d2b9226 100644 --- a/py-polars/polars/utils/_parse_expr_input.py +++ b/py-polars/polars/_utils/_parse_expr_input.py @@ -5,8 +5,8 @@ import polars._reexport as pl from polars import functions as F +from polars._utils.deprecation import issue_deprecation_warning from polars.exceptions import ComputeError -from polars.utils.deprecation import issue_deprecation_warning with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/utils/_polars_version.py b/py-polars/polars/_utils/_polars_version.py similarity index 100% rename from py-polars/polars/utils/_polars_version.py rename to py-polars/polars/_utils/_polars_version.py diff --git a/py-polars/polars/utils/_scan.py b/py-polars/polars/_utils/_scan.py similarity index 100% rename from py-polars/polars/utils/_scan.py rename to py-polars/polars/_utils/_scan.py diff --git a/py-polars/polars/utils/_wrap.py b/py-polars/polars/_utils/_wrap.py similarity index 100% rename from py-polars/polars/utils/_wrap.py rename to py-polars/polars/_utils/_wrap.py diff --git a/py-polars/polars/utils/convert.py b/py-polars/polars/_utils/convert.py similarity index 100% rename from py-polars/polars/utils/convert.py rename to py-polars/polars/_utils/convert.py diff --git a/py-polars/polars/utils/deprecation.py b/py-polars/polars/_utils/deprecation.py similarity index 99% rename from py-polars/polars/utils/deprecation.py rename to py-polars/polars/_utils/deprecation.py index a95d711ebc5f..515c57daaa56 100644 --- a/py-polars/polars/utils/deprecation.py +++ b/py-polars/polars/_utils/deprecation.py @@ -5,7 +5,7 @@ from functools import wraps from typing import TYPE_CHECKING, Callable, Sequence, TypeVar -from polars.utils.various import find_stacklevel +from polars._utils.various import find_stacklevel if TYPE_CHECKING: import sys diff --git a/py-polars/polars/utils/udfs.py b/py-polars/polars/_utils/udfs.py similarity index 99% rename from py-polars/polars/utils/udfs.py rename to py-polars/polars/_utils/udfs.py index 57c58094dbef..3cf27d1a7e07 100644 --- a/py-polars/polars/utils/udfs.py +++ b/py-polars/polars/_utils/udfs.py @@ -25,7 +25,7 @@ Union, ) -from polars.utils.various import re_escape +from polars._utils.various import re_escape if TYPE_CHECKING: from dis import Instruction @@ -451,11 +451,11 @@ def warn( """Generate warning that suggests an equivalent native polars expression.""" # Import these here so that udfs can be imported without polars installed. - from polars.exceptions import PolarsInefficientMapWarning - from polars.utils.various import ( + from polars._utils.various import ( find_stacklevel, in_terminal_that_supports_colour, ) + from polars.exceptions import PolarsInefficientMapWarning suggested_expression = suggestion_override or self.to_expression(col) diff --git a/py-polars/polars/utils/unstable.py b/py-polars/polars/_utils/unstable.py similarity index 97% rename from py-polars/polars/utils/unstable.py rename to py-polars/polars/_utils/unstable.py index e00c9177e06b..3ad2e4fde306 100644 --- a/py-polars/polars/utils/unstable.py +++ b/py-polars/polars/_utils/unstable.py @@ -6,8 +6,8 @@ from functools import wraps from typing import TYPE_CHECKING, Callable, TypeVar +from polars._utils.various import find_stacklevel from polars.exceptions import UnstableWarning -from polars.utils.various import find_stacklevel if TYPE_CHECKING: import sys diff --git a/py-polars/polars/utils/various.py b/py-polars/polars/_utils/various.py similarity index 99% rename from py-polars/polars/utils/various.py rename to py-polars/polars/_utils/various.py index d06e604ead34..e689cf2ea632 100644 --- a/py-polars/polars/utils/various.py +++ b/py-polars/polars/_utils/various.py @@ -385,7 +385,7 @@ def str_duration_(td: str | None) -> int | None: NS = TypeVar("NS") -class sphinx_accessor(property): # noqa: D101 +class sphinx_accessor(property): def __get__( # type: ignore[override] self, instance: Any, diff --git a/py-polars/polars/api.py b/py-polars/polars/api.py index f1020b50bc09..00cbb1673344 100644 --- a/py-polars/polars/api.py +++ b/py-polars/polars/api.py @@ -6,7 +6,7 @@ from warnings import warn import polars._reexport as pl -from polars.utils.various import find_stacklevel +from polars._utils.various import find_stacklevel if TYPE_CHECKING: from polars import DataFrame, Expr, LazyFrame, Series diff --git a/py-polars/polars/config.py b/py-polars/polars/config.py index a481597f3ae0..0aabe4d59a6a 100644 --- a/py-polars/polars/config.py +++ b/py-polars/polars/config.py @@ -6,9 +6,9 @@ from pathlib import Path from typing import TYPE_CHECKING, Any, Literal, get_args +from polars._utils.deprecation import deprecate_nonkeyword_arguments +from polars._utils.various import normalize_filepath from polars.dependencies import json -from polars.utils.deprecation import deprecate_nonkeyword_arguments -from polars.utils.various import normalize_filepath if sys.version_info >= (3, 10): from typing import TypeAlias diff --git a/py-polars/polars/convert.py b/py-polars/polars/convert.py index ed5ea49f21d7..a5deab752fe2 100644 --- a/py-polars/polars/convert.py +++ b/py-polars/polars/convert.py @@ -7,12 +7,12 @@ import polars._reexport as pl from polars import functions as F +from polars._utils.various import _cast_repr_strings_with_schema from polars.datatypes import N_INFER_DEFAULT, Categorical, List, Object, String, Struct from polars.dependencies import pandas as pd from polars.dependencies import pyarrow as pa from polars.exceptions import NoDataError from polars.io import read_csv -from polars.utils.various import _cast_repr_strings_with_schema if TYPE_CHECKING: from polars import DataFrame, Series diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index b4728041aae2..ebfec171a83a 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -31,6 +31,43 @@ import polars._reexport as pl from polars import functions as F +from polars._utils._construction import ( + arrow_to_pydf, + dict_to_pydf, + frame_to_pydf, + iterable_to_pydf, + numpy_to_idxs, + numpy_to_pydf, + pandas_to_pydf, + sequence_to_pydf, + series_to_pydf, +) +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr, wrap_ldf, wrap_s +from polars._utils.convert import parse_as_duration_string +from polars._utils.deprecation import ( + deprecate_function, + deprecate_nonkeyword_arguments, + deprecate_parameter_as_positional, + deprecate_renamed_function, + deprecate_renamed_parameter, + deprecate_saturating, + issue_deprecation_warning, +) +from polars._utils.unstable import issue_unstable_warning, unstable +from polars._utils.various import ( + _prepare_row_index_args, + _process_null_values, + handle_projection_columns, + is_bool_sequence, + is_int_sequence, + is_str_sequence, + normalize_filepath, + parse_version, + range_to_slice, + scale_bytes, + warn_null_comparison, +) from polars.dataframe._html import NotebookFormatter from polars.dataframe.group_by import DynamicGroupBy, GroupBy, RollingGroupBy from polars.datatypes import ( @@ -76,43 +113,6 @@ from polars.selectors import _expand_selector_dicts, _expand_selectors from polars.slice import PolarsSlice from polars.type_aliases import DbWriteMode -from polars.utils._construction import ( - arrow_to_pydf, - dict_to_pydf, - frame_to_pydf, - iterable_to_pydf, - numpy_to_idxs, - numpy_to_pydf, - pandas_to_pydf, - sequence_to_pydf, - series_to_pydf, -) -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr, wrap_ldf, wrap_s -from polars.utils.convert import parse_as_duration_string -from polars.utils.deprecation import ( - deprecate_function, - deprecate_nonkeyword_arguments, - deprecate_parameter_as_positional, - deprecate_renamed_function, - deprecate_renamed_parameter, - deprecate_saturating, - issue_deprecation_warning, -) -from polars.utils.unstable import issue_unstable_warning, unstable -from polars.utils.various import ( - _prepare_row_index_args, - _process_null_values, - handle_projection_columns, - is_bool_sequence, - is_int_sequence, - is_str_sequence, - normalize_filepath, - parse_version, - range_to_slice, - scale_bytes, - warn_null_comparison, -) with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PyDataFrame diff --git a/py-polars/polars/dataframe/group_by.py b/py-polars/polars/dataframe/group_by.py index f6ad0144098b..789468987ca4 100644 --- a/py-polars/polars/dataframe/group_by.py +++ b/py-polars/polars/dataframe/group_by.py @@ -3,8 +3,8 @@ from typing import TYPE_CHECKING, Callable, Iterable, Iterator from polars import functions as F -from polars.utils.convert import parse_as_duration_string -from polars.utils.deprecation import ( +from polars._utils.convert import parse_as_duration_string +from polars._utils.deprecation import ( deprecate_renamed_function, issue_deprecation_warning, ) diff --git a/py-polars/polars/datatypes/classes.py b/py-polars/polars/datatypes/classes.py index 014a2e94437a..370c3f290b8c 100644 --- a/py-polars/polars/datatypes/classes.py +++ b/py-polars/polars/datatypes/classes.py @@ -168,7 +168,7 @@ def is_not(self, other: PolarsDataType) -> bool: >>> pl.List.is_not(pl.List(pl.Int32)) # doctest: +SKIP True """ - from polars.utils.deprecation import issue_deprecation_warning + from polars._utils.deprecation import issue_deprecation_warning issue_deprecation_warning( "`DataType.is_not` is deprecated and will be removed in the next breaking release." @@ -382,7 +382,7 @@ def __init__( ): # Issuing the warning on `__init__` does not trigger when the class is used # without being instantiated, but it's better than nothing - from polars.utils.unstable import issue_unstable_warning + from polars._utils.unstable import issue_unstable_warning issue_unstable_warning( "The Decimal data type is considered unstable." @@ -488,7 +488,7 @@ def __init__( self, time_unit: TimeUnit = "us", time_zone: str | timezone | None = None ): if time_unit is None: - from polars.utils.deprecation import issue_deprecation_warning + from polars._utils.deprecation import issue_deprecation_warning issue_deprecation_warning( "Passing `time_unit=None` to the Datetime constructor is deprecated." @@ -634,7 +634,7 @@ class Enum(DataType): def __init__(self, categories: Series | Iterable[str]): # Issuing the warning on `__init__` does not trigger when the class is used # without being instantiated, but it's better than nothing - from polars.utils.unstable import issue_unstable_warning + from polars._utils.unstable import issue_unstable_warning issue_unstable_warning( "The Enum data type is considered unstable." diff --git a/py-polars/polars/datatypes/convert.py b/py-polars/polars/datatypes/convert.py index c7da2453d064..8279ef4dce86 100644 --- a/py-polars/polars/datatypes/convert.py +++ b/py-polars/polars/datatypes/convert.py @@ -485,7 +485,7 @@ def numpy_char_code_to_dtype(dtype_char: str) -> PolarsDataType: def maybe_cast(el: Any, dtype: PolarsDataType) -> Any: """Try casting a value to a value that is valid for the given Polars dtype.""" # cast el if it doesn't match - from polars.utils.convert import ( + from polars._utils.convert import ( datetime_to_int, timedelta_to_int, ) diff --git a/py-polars/polars/dependencies.py b/py-polars/polars/dependencies.py index 1cc61eb4609c..61d37c3877a8 100644 --- a/py-polars/polars/dependencies.py +++ b/py-polars/polars/dependencies.py @@ -244,8 +244,8 @@ def import_optional( min_version : {str, tuple[int]}, optional If a minimum module version is required, specify it here. """ + from polars._utils.various import parse_version from polars.exceptions import ModuleUpgradeRequired - from polars.utils.various import parse_version try: module = import_module(module_name) diff --git a/py-polars/polars/expr/array.py b/py-polars/polars/expr/array.py index b228b7b562b7..fcd8e2cab5ef 100644 --- a/py-polars/polars/expr/array.py +++ b/py-polars/polars/expr/array.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING, Callable, Sequence -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr if TYPE_CHECKING: from datetime import date, datetime, time diff --git a/py-polars/polars/expr/binary.py b/py-polars/polars/expr/binary.py index ed1af57c8b2d..59aae759b7c1 100644 --- a/py-polars/polars/expr/binary.py +++ b/py-polars/polars/expr/binary.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/categorical.py b/py-polars/polars/expr/categorical.py index 89ecef5188ea..2ae258bf414e 100644 --- a/py-polars/polars/expr/categorical.py +++ b/py-polars/polars/expr/categorical.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import deprecate_function +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import deprecate_function if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/datetime.py b/py-polars/polars/expr/datetime.py index 823f56604644..caf6b86f678d 100644 --- a/py-polars/polars/expr/datetime.py +++ b/py-polars/polars/expr/datetime.py @@ -5,18 +5,18 @@ import polars._reexport as pl from polars import functions as F -from polars.datatypes import DTYPE_TEMPORAL_UNITS, Date, Int32 -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr -from polars.utils.convert import parse_as_duration_string -from polars.utils.deprecation import ( +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr +from polars._utils.convert import parse_as_duration_string +from polars._utils.deprecation import ( deprecate_function, deprecate_renamed_function, deprecate_saturating, issue_deprecation_warning, rename_use_earliest_to_ambiguous, ) -from polars.utils.unstable import unstable +from polars._utils.unstable import unstable +from polars.datatypes import DTYPE_TEMPORAL_UNITS, Date, Int32 if TYPE_CHECKING: from datetime import timedelta diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index 699de0973a4b..d5cb035464e4 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -25,31 +25,13 @@ import polars._reexport as pl from polars import functions as F -from polars.datatypes import ( - Int64, - is_polars_dtype, - py_type_to_dtype, -) -from polars.dependencies import _check_for_numpy -from polars.dependencies import numpy as np -from polars.exceptions import CustomUFuncWarning, PolarsInefficientMapWarning -from polars.expr.array import ExprArrayNameSpace -from polars.expr.binary import ExprBinaryNameSpace -from polars.expr.categorical import ExprCatNameSpace -from polars.expr.datetime import ExprDateTimeNameSpace -from polars.expr.list import ExprListNameSpace -from polars.expr.meta import ExprMetaNameSpace -from polars.expr.name import ExprNameNameSpace -from polars.expr.string import ExprStringNameSpace -from polars.expr.struct import ExprStructNameSpace -from polars.meta import thread_pool_size -from polars.utils._parse_expr_input import ( +from polars._utils._parse_expr_input import ( parse_as_expression, parse_as_list_of_expressions, parse_predicates_constraints_as_expression, ) -from polars.utils.convert import negate_duration_string, parse_as_duration_string -from polars.utils.deprecation import ( +from polars._utils.convert import negate_duration_string, parse_as_duration_string +from polars._utils.deprecation import ( deprecate_function, deprecate_nonkeyword_arguments, deprecate_renamed_function, @@ -57,8 +39,8 @@ deprecate_saturating, issue_deprecation_warning, ) -from polars.utils.unstable import issue_unstable_warning, unstable -from polars.utils.various import ( +from polars._utils.unstable import issue_unstable_warning, unstable +from polars._utils.various import ( BUILDING_SPHINX_DOCS, find_stacklevel, no_default, @@ -66,6 +48,24 @@ sphinx_accessor, warn_null_comparison, ) +from polars.datatypes import ( + Int64, + is_polars_dtype, + py_type_to_dtype, +) +from polars.dependencies import _check_for_numpy +from polars.dependencies import numpy as np +from polars.exceptions import CustomUFuncWarning, PolarsInefficientMapWarning +from polars.expr.array import ExprArrayNameSpace +from polars.expr.binary import ExprBinaryNameSpace +from polars.expr.categorical import ExprCatNameSpace +from polars.expr.datetime import ExprDateTimeNameSpace +from polars.expr.list import ExprListNameSpace +from polars.expr.meta import ExprMetaNameSpace +from polars.expr.name import ExprNameNameSpace +from polars.expr.string import ExprStringNameSpace +from polars.expr.struct import ExprStructNameSpace +from polars.meta import thread_pool_size with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import arg_where as py_arg_where @@ -78,6 +78,9 @@ from io import IOBase from polars import DataFrame, LazyFrame, Series + from polars._utils.various import ( + NoDefault, + ) from polars.type_aliases import ( ClosedInterval, FillNullStrategy, @@ -94,9 +97,6 @@ TemporalLiteral, WindowMappingStrategy, ) - from polars.utils.various import ( - NoDefault, - ) if sys.version_info >= (3, 11): from typing import Concatenate, ParamSpec, Self @@ -4358,7 +4358,7 @@ def map_elements( ) # input x: Series of type list containing the group values - from polars.utils.udfs import warn_on_inefficient_map + from polars._utils.udfs import warn_on_inefficient_map root_names = self.meta.root_names() if len(root_names) > 0: diff --git a/py-polars/polars/expr/list.py b/py-polars/polars/expr/list.py index 71139e65cb66..d82ae599cf75 100644 --- a/py-polars/polars/expr/list.py +++ b/py-polars/polars/expr/list.py @@ -5,9 +5,9 @@ import polars._reexport as pl from polars import functions as F -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import ( +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, ) diff --git a/py-polars/polars/expr/meta.py b/py-polars/polars/expr/meta.py index 0c6c3fde46d7..03f4485a0f64 100644 --- a/py-polars/polars/expr/meta.py +++ b/py-polars/polars/expr/meta.py @@ -4,13 +4,13 @@ from pathlib import Path from typing import TYPE_CHECKING, Literal, overload -from polars.exceptions import ComputeError -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import ( +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import ( deprecate_nonkeyword_arguments, deprecate_renamed_function, ) -from polars.utils.various import normalize_filepath +from polars._utils.various import normalize_filepath +from polars.exceptions import ComputeError if TYPE_CHECKING: from io import IOBase diff --git a/py-polars/polars/expr/string.py b/py-polars/polars/expr/string.py index aa2fcf6d49e3..d908b5f05b42 100644 --- a/py-polars/polars/expr/string.py +++ b/py-polars/polars/expr/string.py @@ -5,18 +5,18 @@ import polars._reexport as pl from polars import functions as F -from polars.datatypes import Date, Datetime, Int32, Time, py_type_to_dtype -from polars.datatypes.constants import N_INFER_DEFAULT -from polars.exceptions import ChronoFormatWarning -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import ( +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, issue_deprecation_warning, rename_use_earliest_to_ambiguous, ) -from polars.utils.various import find_stacklevel +from polars._utils.various import find_stacklevel +from polars.datatypes import Date, Datetime, Int32, Time, py_type_to_dtype +from polars.datatypes.constants import N_INFER_DEFAULT +from polars.exceptions import ChronoFormatWarning if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/struct.py b/py-polars/polars/expr/struct.py index a8669b2f3317..d2860469c4e3 100644 --- a/py-polars/polars/expr/struct.py +++ b/py-polars/polars/expr/struct.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Sequence -from polars.utils._wrap import wrap_expr +from polars._utils._wrap import wrap_expr if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/whenthen.py b/py-polars/polars/expr/whenthen.py index ced5df6d68fe..0bc7f683618f 100644 --- a/py-polars/polars/expr/whenthen.py +++ b/py-polars/polars/expr/whenthen.py @@ -3,12 +3,12 @@ from typing import TYPE_CHECKING, Any, Iterable import polars.functions as F -from polars.expr.expr import Expr -from polars.utils._parse_expr_input import ( +from polars._utils._parse_expr_input import ( parse_as_expression, parse_when_inputs, ) -from polars.utils._wrap import wrap_expr +from polars._utils._wrap import wrap_expr +from polars.expr.expr import Expr if TYPE_CHECKING: from polars.polars import PyExpr diff --git a/py-polars/polars/functions/aggregation/horizontal.py b/py-polars/polars/functions/aggregation/horizontal.py index 6d06aab8162c..c3fe9cde4604 100644 --- a/py-polars/polars/functions/aggregation/horizontal.py +++ b/py-polars/polars/functions/aggregation/horizontal.py @@ -4,10 +4,10 @@ from typing import TYPE_CHECKING, Iterable import polars.functions as F +from polars._utils._parse_expr_input import parse_as_list_of_expressions +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import deprecate_renamed_function from polars.datatypes import UInt32 -from polars.utils._parse_expr_input import parse_as_list_of_expressions -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import deprecate_renamed_function with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/aggregation/vertical.py b/py-polars/polars/functions/aggregation/vertical.py index 16828027f3dd..ecae33eac192 100644 --- a/py-polars/polars/functions/aggregation/vertical.py +++ b/py-polars/polars/functions/aggregation/vertical.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING import polars.functions as F -from polars.utils.deprecation import deprecate_renamed_function +from polars._utils.deprecation import deprecate_renamed_function if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/functions/as_datatype.py b/py-polars/polars/functions/as_datatype.py index 02d220868075..f0c1ddd1a5ec 100644 --- a/py-polars/polars/functions/as_datatype.py +++ b/py-polars/polars/functions/as_datatype.py @@ -4,13 +4,13 @@ from typing import TYPE_CHECKING, Iterable, overload from polars import functions as F -from polars.datatypes import Date, Struct, Time -from polars.utils._parse_expr_input import ( +from polars._utils._parse_expr_input import ( parse_as_expression, parse_as_list_of_expressions, ) -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import rename_use_earliest_to_ambiguous +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import rename_use_earliest_to_ambiguous +from polars.datatypes import Date, Struct, Time with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/col.py b/py-polars/polars/functions/col.py index da5debc32de4..6ae8aa0ca421 100644 --- a/py-polars/polars/functions/col.py +++ b/py-polars/polars/functions/col.py @@ -3,8 +3,8 @@ import contextlib from typing import TYPE_CHECKING, Any, Iterable, Protocol, cast +from polars._utils._wrap import wrap_expr from polars.datatypes import is_polars_dtype -from polars.utils._wrap import wrap_expr plr: Any = None with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/eager.py b/py-polars/polars/functions/eager.py index 573fac1912c1..3b935fad15ad 100644 --- a/py-polars/polars/functions/eager.py +++ b/py-polars/polars/functions/eager.py @@ -7,10 +7,10 @@ import polars._reexport as pl from polars import functions as F +from polars._utils._wrap import wrap_df, wrap_expr, wrap_ldf, wrap_s +from polars._utils.various import ordered_unique from polars.exceptions import InvalidOperationError from polars.type_aliases import ConcatMethod, FrameType -from polars.utils._wrap import wrap_df, wrap_expr, wrap_ldf, wrap_s -from polars.utils.various import ordered_unique with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/lazy.py b/py-polars/polars/functions/lazy.py index bbd1e1d14b38..9fcbbca3ef3e 100644 --- a/py-polars/polars/functions/lazy.py +++ b/py-polars/polars/functions/lazy.py @@ -5,19 +5,19 @@ import polars._reexport as pl import polars.functions as F -from polars.datatypes import DTYPE_TEMPORAL_UNITS, Date, Datetime, Int64, UInt32 -from polars.utils._async import _AioDataFrameResult, _GeventDataFrameResult -from polars.utils._parse_expr_input import ( +from polars._utils._async import _AioDataFrameResult, _GeventDataFrameResult +from polars._utils._parse_expr_input import ( parse_as_expression, parse_as_list_of_expressions, ) -from polars.utils._wrap import wrap_df, wrap_expr -from polars.utils.deprecation import ( +from polars._utils._wrap import wrap_df, wrap_expr +from polars._utils.deprecation import ( deprecate_parameter_as_positional, deprecate_renamed_function, issue_deprecation_warning, ) -from polars.utils.unstable import issue_unstable_warning, unstable +from polars._utils.unstable import issue_unstable_warning, unstable +from polars.datatypes import DTYPE_TEMPORAL_UNITS, Date, Datetime, Int64, UInt32 with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/len.py b/py-polars/polars/functions/len.py index f34a3e84cbe2..fb4435e8d383 100644 --- a/py-polars/polars/functions/len.py +++ b/py-polars/polars/functions/len.py @@ -8,7 +8,7 @@ import contextlib from typing import TYPE_CHECKING -from polars.utils._wrap import wrap_expr +from polars._utils._wrap import wrap_expr with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/lit.py b/py-polars/polars/functions/lit.py index b02aa57e6ce1..dd01013508ff 100644 --- a/py-polars/polars/functions/lit.py +++ b/py-polars/polars/functions/lit.py @@ -5,16 +5,16 @@ from typing import TYPE_CHECKING, Any import polars._reexport as pl -from polars.datatypes import Date, Datetime, Duration, Time -from polars.dependencies import _check_for_numpy -from polars.dependencies import numpy as np -from polars.utils._wrap import wrap_expr -from polars.utils.convert import ( +from polars._utils._wrap import wrap_expr +from polars._utils.convert import ( date_to_int, datetime_to_int, time_to_int, timedelta_to_int, ) +from polars.datatypes import Date, Datetime, Duration, Time +from polars.dependencies import _check_for_numpy +from polars.dependencies import numpy as np with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/range/_utils.py b/py-polars/polars/functions/range/_utils.py index 173125996ef7..86bdeedd15cd 100644 --- a/py-polars/polars/functions/range/_utils.py +++ b/py-polars/polars/functions/range/_utils.py @@ -2,7 +2,7 @@ from datetime import timedelta -from polars.utils.convert import parse_as_duration_string +from polars._utils.convert import parse_as_duration_string def parse_interval_argument(interval: str | timedelta) -> str: diff --git a/py-polars/polars/functions/range/date_range.py b/py-polars/polars/functions/range/date_range.py index ae6e0af5dea1..91e1699129e6 100644 --- a/py-polars/polars/functions/range/date_range.py +++ b/py-polars/polars/functions/range/date_range.py @@ -5,13 +5,13 @@ from typing import TYPE_CHECKING, overload from polars import functions as F -from polars.functions.range._utils import parse_interval_argument -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import ( +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import ( deprecate_saturating, issue_deprecation_warning, ) +from polars.functions.range._utils import parse_interval_argument with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/range/datetime_range.py b/py-polars/polars/functions/range/datetime_range.py index 76321e59b0a5..eafbbab9b92e 100644 --- a/py-polars/polars/functions/range/datetime_range.py +++ b/py-polars/polars/functions/range/datetime_range.py @@ -4,10 +4,10 @@ from typing import TYPE_CHECKING, overload from polars import functions as F +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import deprecate_saturating from polars.functions.range._utils import parse_interval_argument -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import deprecate_saturating with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/range/int_range.py b/py-polars/polars/functions/range/int_range.py index c23e0196a8e2..f1c1c3fc6b04 100644 --- a/py-polars/polars/functions/range/int_range.py +++ b/py-polars/polars/functions/range/int_range.py @@ -4,9 +4,9 @@ from typing import TYPE_CHECKING, overload from polars import functions as F +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr, wrap_s from polars.datatypes import Int64 -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr, wrap_s with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/range/time_range.py b/py-polars/polars/functions/range/time_range.py index 5563e072b357..54e0b01d62cf 100644 --- a/py-polars/polars/functions/range/time_range.py +++ b/py-polars/polars/functions/range/time_range.py @@ -5,10 +5,10 @@ from typing import TYPE_CHECKING, overload from polars import functions as F +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr +from polars._utils.deprecation import deprecate_saturating from polars.functions.range._utils import parse_interval_argument -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr -from polars.utils.deprecation import deprecate_saturating with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/repeat.py b/py-polars/polars/functions/repeat.py index c922a5a05503..b2d15c7fcff9 100644 --- a/py-polars/polars/functions/repeat.py +++ b/py-polars/polars/functions/repeat.py @@ -6,6 +6,8 @@ from typing import TYPE_CHECKING, Any, overload from polars import functions as F +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr from polars.datatypes import ( FLOAT_DTYPES, INTEGER_DTYPES, @@ -16,8 +18,6 @@ List, Utf8, ) -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/whenthen.py b/py-polars/polars/functions/whenthen.py index 77ab37a09c02..091ad0a7d7a8 100644 --- a/py-polars/polars/functions/whenthen.py +++ b/py-polars/polars/functions/whenthen.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Iterable import polars._reexport as pl -from polars.utils._parse_expr_input import parse_when_inputs +from polars._utils._parse_expr_input import parse_when_inputs with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/io/_utils.py b/py-polars/polars/io/_utils.py index 2efbb3616d48..66afaf637016 100644 --- a/py-polars/polars/io/_utils.py +++ b/py-polars/polars/io/_utils.py @@ -8,9 +8,9 @@ from tempfile import NamedTemporaryFile from typing import IO, Any, ContextManager, Iterator, cast, overload +from polars._utils.various import normalize_filepath from polars.dependencies import _FSSPEC_AVAILABLE, fsspec from polars.exceptions import NoDataError -from polars.utils.various import normalize_filepath def _is_glob_pattern(file: str) -> bool: diff --git a/py-polars/polars/io/csv/batched_reader.py b/py-polars/polars/io/csv/batched_reader.py index a4f416e8a268..238a0dc8b35f 100644 --- a/py-polars/polars/io/csv/batched_reader.py +++ b/py-polars/polars/io/csv/batched_reader.py @@ -3,15 +3,15 @@ import contextlib from typing import TYPE_CHECKING, Sequence -from polars.datatypes import N_INFER_DEFAULT, py_type_to_dtype -from polars.io.csv._utils import _update_columns -from polars.utils._wrap import wrap_df -from polars.utils.various import ( +from polars._utils._wrap import wrap_df +from polars._utils.various import ( _prepare_row_index_args, _process_null_values, handle_projection_columns, normalize_filepath, ) +from polars.datatypes import N_INFER_DEFAULT, py_type_to_dtype +from polars.io.csv._utils import _update_columns with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PyBatchedCsv diff --git a/py-polars/polars/io/csv/functions.py b/py-polars/polars/io/csv/functions.py index e3ad2cd5c80f..9291345a9a60 100644 --- a/py-polars/polars/io/csv/functions.py +++ b/py-polars/polars/io/csv/functions.py @@ -4,12 +4,12 @@ from typing import IO, TYPE_CHECKING, Any, Callable, Mapping, Sequence import polars._reexport as pl +from polars._utils.deprecation import deprecate_renamed_parameter +from polars._utils.various import handle_projection_columns, normalize_filepath from polars.datatypes import N_INFER_DEFAULT, String from polars.io._utils import _prepare_file_arg from polars.io.csv._utils import _check_arg_is_1byte, _update_columns from polars.io.csv.batched_reader import BatchedCsvReader -from polars.utils.deprecation import deprecate_renamed_parameter -from polars.utils.various import handle_projection_columns, normalize_filepath if TYPE_CHECKING: from polars import DataFrame, LazyFrame diff --git a/py-polars/polars/io/database.py b/py-polars/polars/io/database.py index 76db913aeb02..c7d6d9d3a08c 100644 --- a/py-polars/polars/io/database.py +++ b/py-polars/polars/io/database.py @@ -6,9 +6,9 @@ from inspect import Parameter, signature from typing import TYPE_CHECKING, Any, Iterable, Literal, Sequence, TypedDict, overload +from polars._utils.deprecation import issue_deprecation_warning from polars.convert import from_arrow from polars.exceptions import InvalidOperationError, UnsuitableSQLError -from polars.utils.deprecation import issue_deprecation_warning if TYPE_CHECKING: from types import TracebackType diff --git a/py-polars/polars/io/iceberg.py b/py-polars/polars/io/iceberg.py index fd5d3f6a4aa1..ec57b401c907 100644 --- a/py-polars/polars/io/iceberg.py +++ b/py-polars/polars/io/iceberg.py @@ -21,8 +21,8 @@ from typing import TYPE_CHECKING, Any, Callable import polars._reexport as pl +from polars._utils.convert import to_py_date, to_py_datetime from polars.dependencies import pyiceberg -from polars.utils.convert import to_py_date, to_py_datetime if TYPE_CHECKING: from datetime import date, datetime diff --git a/py-polars/polars/io/ipc/functions.py b/py-polars/polars/io/ipc/functions.py index 411ed43043d9..ddec69601732 100644 --- a/py-polars/polars/io/ipc/functions.py +++ b/py-polars/polars/io/ipc/functions.py @@ -5,10 +5,10 @@ from typing import IO, TYPE_CHECKING, Any import polars._reexport as pl +from polars._utils.deprecation import deprecate_renamed_parameter +from polars._utils.various import normalize_filepath from polars.dependencies import _PYARROW_AVAILABLE from polars.io._utils import _prepare_file_arg -from polars.utils.deprecation import deprecate_renamed_parameter -from polars.utils.various import normalize_filepath with contextlib.suppress(ImportError): from polars.polars import read_ipc_schema as _read_ipc_schema diff --git a/py-polars/polars/io/ndjson.py b/py-polars/polars/io/ndjson.py index d8e5aa9d403a..9d413e6de10d 100644 --- a/py-polars/polars/io/ndjson.py +++ b/py-polars/polars/io/ndjson.py @@ -3,8 +3,8 @@ from typing import TYPE_CHECKING import polars._reexport as pl +from polars._utils.deprecation import deprecate_renamed_parameter from polars.datatypes import N_INFER_DEFAULT -from polars.utils.deprecation import deprecate_renamed_parameter if TYPE_CHECKING: from io import IOBase diff --git a/py-polars/polars/io/parquet/functions.py b/py-polars/polars/io/parquet/functions.py index a80da70569a3..8c0acd413a9f 100644 --- a/py-polars/polars/io/parquet/functions.py +++ b/py-polars/polars/io/parquet/functions.py @@ -6,11 +6,11 @@ from typing import IO, TYPE_CHECKING, Any import polars._reexport as pl +from polars._utils.deprecation import deprecate_renamed_parameter +from polars._utils.various import is_int_sequence, normalize_filepath from polars.convert import from_arrow from polars.dependencies import _PYARROW_AVAILABLE from polars.io._utils import _prepare_file_arg -from polars.utils.deprecation import deprecate_renamed_parameter -from polars.utils.various import is_int_sequence, normalize_filepath with contextlib.suppress(ImportError): from polars.polars import read_parquet_schema as _read_parquet_schema diff --git a/py-polars/polars/io/pyarrow_dataset/anonymous_scan.py b/py-polars/polars/io/pyarrow_dataset/anonymous_scan.py index df639d478a96..5ecaeacff2ca 100644 --- a/py-polars/polars/io/pyarrow_dataset/anonymous_scan.py +++ b/py-polars/polars/io/pyarrow_dataset/anonymous_scan.py @@ -71,13 +71,13 @@ def _scan_pyarrow_dataset_impl( _filter = None if predicate: - from polars.datatypes import Date, Datetime, Duration - from polars.utils.convert import ( + from polars._utils.convert import ( to_py_date, to_py_datetime, to_py_time, to_py_timedelta, ) + from polars.datatypes import Date, Datetime, Duration _filter = eval( predicate, diff --git a/py-polars/polars/io/pyarrow_dataset/functions.py b/py-polars/polars/io/pyarrow_dataset/functions.py index f1d6edf8b1eb..2d23a95bddfd 100644 --- a/py-polars/polars/io/pyarrow_dataset/functions.py +++ b/py-polars/polars/io/pyarrow_dataset/functions.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING +from polars._utils.unstable import unstable from polars.io.pyarrow_dataset.anonymous_scan import _scan_pyarrow_dataset -from polars.utils.unstable import unstable if TYPE_CHECKING: from polars import LazyFrame diff --git a/py-polars/polars/io/spreadsheet/functions.py b/py-polars/polars/io/spreadsheet/functions.py index 1053e4b6f2cf..3dccdb347b0a 100644 --- a/py-polars/polars/io/spreadsheet/functions.py +++ b/py-polars/polars/io/spreadsheet/functions.py @@ -9,6 +9,8 @@ import polars._reexport as pl from polars import functions as F +from polars._utils.deprecation import deprecate_renamed_parameter +from polars._utils.various import normalize_filepath from polars.datatypes import ( FLOAT_DTYPES, NUMERIC_DTYPES, @@ -22,8 +24,6 @@ from polars.exceptions import NoDataError, ParameterCollisionError from polars.io._utils import PortableTemporaryFile, _looks_like_url, _process_file_url from polars.io.csv.functions import read_csv -from polars.utils.deprecation import deprecate_renamed_parameter -from polars.utils.various import normalize_filepath if TYPE_CHECKING: from typing import Literal diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index 0d1d8ed8c3e4..a5f7c07d122d 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -24,6 +24,31 @@ import polars._reexport as pl from polars import functions as F +from polars._utils._async import _AioDataFrameResult, _GeventDataFrameResult +from polars._utils._parse_expr_input import ( + parse_as_expression, + parse_as_list_of_expressions, +) +from polars._utils._wrap import wrap_df, wrap_expr +from polars._utils.convert import negate_duration_string, parse_as_duration_string +from polars._utils.deprecation import ( + deprecate_function, + deprecate_parameter_as_positional, + deprecate_renamed_function, + deprecate_renamed_parameter, + deprecate_saturating, + issue_deprecation_warning, +) +from polars._utils.unstable import issue_unstable_warning, unstable +from polars._utils.various import ( + _in_notebook, + _prepare_row_index_args, + _process_null_values, + is_bool_sequence, + is_sequence, + normalize_filepath, + parse_percentiles, +) from polars.convert import from_dict from polars.datatypes import ( DTYPE_TEMPORAL_UNITS, @@ -62,31 +87,6 @@ from polars.lazyframe.in_process import InProcessQuery from polars.selectors import _expand_selectors, by_dtype, expand_selector from polars.slice import LazyPolarsSlice -from polars.utils._async import _AioDataFrameResult, _GeventDataFrameResult -from polars.utils._parse_expr_input import ( - parse_as_expression, - parse_as_list_of_expressions, -) -from polars.utils._wrap import wrap_df, wrap_expr -from polars.utils.convert import negate_duration_string, parse_as_duration_string -from polars.utils.deprecation import ( - deprecate_function, - deprecate_parameter_as_positional, - deprecate_renamed_function, - deprecate_renamed_parameter, - deprecate_saturating, - issue_deprecation_warning, -) -from polars.utils.unstable import issue_unstable_warning, unstable -from polars.utils.various import ( - _in_notebook, - _prepare_row_index_args, - _process_null_values, - is_bool_sequence, - is_sequence, - normalize_filepath, - parse_percentiles, -) with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PyLazyFrame diff --git a/py-polars/polars/lazyframe/group_by.py b/py-polars/polars/lazyframe/group_by.py index ca6b712bc481..74e54c69508f 100644 --- a/py-polars/polars/lazyframe/group_by.py +++ b/py-polars/polars/lazyframe/group_by.py @@ -3,9 +3,9 @@ from typing import TYPE_CHECKING, Callable, Iterable from polars import functions as F -from polars.utils._parse_expr_input import parse_as_list_of_expressions -from polars.utils._wrap import wrap_ldf -from polars.utils.deprecation import deprecate_renamed_function +from polars._utils._parse_expr_input import parse_as_list_of_expressions +from polars._utils._wrap import wrap_ldf +from polars._utils.deprecation import deprecate_renamed_function if TYPE_CHECKING: from polars import DataFrame, LazyFrame diff --git a/py-polars/polars/lazyframe/in_process.py b/py-polars/polars/lazyframe/in_process.py index 3c04020a2f68..e389ffb448c1 100644 --- a/py-polars/polars/lazyframe/in_process.py +++ b/py-polars/polars/lazyframe/in_process.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING -from polars.utils._wrap import wrap_df +from polars._utils._wrap import wrap_df if TYPE_CHECKING: from polars import DataFrame diff --git a/py-polars/polars/meta/build.py b/py-polars/polars/meta/build.py index d38d92fc4414..191f2544f32a 100644 --- a/py-polars/polars/meta/build.py +++ b/py-polars/polars/meta/build.py @@ -2,7 +2,7 @@ from typing import Any -from polars.utils._polars_version import get_polars_version +from polars._utils._polars_version import get_polars_version try: from polars.polars import __build__ diff --git a/py-polars/polars/meta/thread_pool.py b/py-polars/polars/meta/thread_pool.py index 446eb486ceb2..c86f358e7e6e 100644 --- a/py-polars/polars/meta/thread_pool.py +++ b/py-polars/polars/meta/thread_pool.py @@ -2,7 +2,7 @@ import contextlib -from polars.utils.deprecation import deprecate_renamed_function +from polars._utils.deprecation import deprecate_renamed_function with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/meta/versions.py b/py-polars/polars/meta/versions.py index 305b2e2a17f8..53bac57cd390 100644 --- a/py-polars/polars/meta/versions.py +++ b/py-polars/polars/meta/versions.py @@ -2,8 +2,8 @@ import sys +from polars._utils._polars_version import get_polars_version from polars.meta.index_type import get_index_type -from polars.utils._polars_version import get_polars_version def show_versions() -> None: diff --git a/py-polars/polars/selectors.py b/py-polars/polars/selectors.py index 846dd4472bd6..80299436e007 100644 --- a/py-polars/polars/selectors.py +++ b/py-polars/polars/selectors.py @@ -7,6 +7,9 @@ from typing import TYPE_CHECKING, Any, Collection, Literal, Mapping, overload from polars import functions as F +from polars._utils._parse_expr_input import _parse_inputs_as_iterable +from polars._utils.deprecation import deprecate_nonkeyword_arguments +from polars._utils.various import is_column from polars.datatypes import ( FLOAT_DTYPES, INTEGER_DTYPES, @@ -27,9 +30,6 @@ is_polars_dtype, ) from polars.expr import Expr -from polars.utils._parse_expr_input import _parse_inputs_as_iterable -from polars.utils.deprecation import deprecate_nonkeyword_arguments -from polars.utils.various import is_column if TYPE_CHECKING: import sys diff --git a/py-polars/polars/series/array.py b/py-polars/polars/series/array.py index 4a547485f962..42111049ae1c 100644 --- a/py-polars/polars/series/array.py +++ b/py-polars/polars/series/array.py @@ -3,8 +3,8 @@ from typing import TYPE_CHECKING, Callable, Sequence from polars import functions as F +from polars._utils._wrap import wrap_s from polars.series.utils import expr_dispatch -from polars.utils._wrap import wrap_s if TYPE_CHECKING: from datetime import date, datetime, time diff --git a/py-polars/polars/series/categorical.py b/py-polars/polars/series/categorical.py index 03057ea81f98..92ea54447b5e 100644 --- a/py-polars/polars/series/categorical.py +++ b/py-polars/polars/series/categorical.py @@ -2,10 +2,10 @@ from typing import TYPE_CHECKING +from polars._utils._wrap import wrap_s +from polars._utils.deprecation import deprecate_function +from polars._utils.unstable import unstable from polars.series.utils import expr_dispatch -from polars.utils._wrap import wrap_s -from polars.utils.deprecation import deprecate_function -from polars.utils.unstable import unstable if TYPE_CHECKING: from polars import Series diff --git a/py-polars/polars/series/datetime.py b/py-polars/polars/series/datetime.py index f4b60d80dc1c..dab5ff81db28 100644 --- a/py-polars/polars/series/datetime.py +++ b/py-polars/polars/series/datetime.py @@ -2,12 +2,12 @@ from typing import TYPE_CHECKING +from polars._utils._wrap import wrap_s +from polars._utils.convert import to_py_date, to_py_datetime +from polars._utils.deprecation import deprecate_function, deprecate_renamed_function +from polars._utils.unstable import unstable from polars.datatypes import Date, Datetime, Duration from polars.series.utils import expr_dispatch -from polars.utils._wrap import wrap_s -from polars.utils.convert import to_py_date, to_py_datetime -from polars.utils.deprecation import deprecate_function, deprecate_renamed_function -from polars.utils.unstable import unstable if TYPE_CHECKING: import datetime as dt diff --git a/py-polars/polars/series/list.py b/py-polars/polars/series/list.py index e7c5eb2f0828..787dfa8fc617 100644 --- a/py-polars/polars/series/list.py +++ b/py-polars/polars/series/list.py @@ -3,12 +3,12 @@ from typing import TYPE_CHECKING, Any, Callable, Sequence from polars import functions as F -from polars.series.utils import expr_dispatch -from polars.utils._wrap import wrap_s -from polars.utils.deprecation import ( +from polars._utils._wrap import wrap_s +from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, ) +from polars.series.utils import expr_dispatch if TYPE_CHECKING: from datetime import date, datetime, time diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index e2500eb91c87..2935ad4f5b74 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -22,6 +22,41 @@ import polars._reexport as pl from polars import functions as F +from polars._utils._construction import ( + arrow_to_pyseries, + dataframe_to_pyseries, + iterable_to_pyseries, + numpy_to_idxs, + numpy_to_pyseries, + pandas_to_pyseries, + sequence_to_pyseries, + series_to_pyseries, +) +from polars._utils._wrap import wrap_df +from polars._utils.convert import ( + date_to_int, + datetime_to_int, + time_to_int, + timedelta_to_int, +) +from polars._utils.deprecation import ( + deprecate_function, + deprecate_nonkeyword_arguments, + deprecate_renamed_function, + deprecate_renamed_parameter, + issue_deprecation_warning, +) +from polars._utils.unstable import unstable +from polars._utils.various import ( + BUILDING_SPHINX_DOCS, + _is_generator, + no_default, + parse_version, + range_to_slice, + scale_bytes, + sphinx_accessor, + warn_null_comparison, +) from polars.datatypes import ( Array, Boolean, @@ -74,41 +109,6 @@ from polars.series.struct import StructNameSpace from polars.series.utils import expr_dispatch, get_ffi_func from polars.slice import PolarsSlice -from polars.utils._construction import ( - arrow_to_pyseries, - dataframe_to_pyseries, - iterable_to_pyseries, - numpy_to_idxs, - numpy_to_pyseries, - pandas_to_pyseries, - sequence_to_pyseries, - series_to_pyseries, -) -from polars.utils._wrap import wrap_df -from polars.utils.convert import ( - date_to_int, - datetime_to_int, - time_to_int, - timedelta_to_int, -) -from polars.utils.deprecation import ( - deprecate_function, - deprecate_nonkeyword_arguments, - deprecate_renamed_function, - deprecate_renamed_parameter, - issue_deprecation_warning, -) -from polars.utils.unstable import unstable -from polars.utils.various import ( - BUILDING_SPHINX_DOCS, - _is_generator, - no_default, - parse_version, - range_to_slice, - scale_bytes, - sphinx_accessor, - warn_null_comparison, -) with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PyDataFrame, PySeries @@ -119,6 +119,9 @@ from hvplot.plotting.core import hvPlotTabularPolars from polars import DataFrame, DataType, Expr + from polars._utils.various import ( + NoDefault, + ) from polars.series._numpy import SeriesView from polars.type_aliases import ( BufferInfo, @@ -140,9 +143,6 @@ SizeUnit, TemporalLiteral, ) - from polars.utils.various import ( - NoDefault, - ) if sys.version_info >= (3, 11): from typing import Self @@ -5289,7 +5289,7 @@ def map_elements( ------- Series """ - from polars.utils.udfs import warn_on_inefficient_map + from polars._utils.udfs import warn_on_inefficient_map if return_dtype is None: pl_return_dtype = None diff --git a/py-polars/polars/series/string.py b/py-polars/polars/series/string.py index 05e385dc5fad..d8cdbef21c4d 100644 --- a/py-polars/polars/series/string.py +++ b/py-polars/polars/series/string.py @@ -2,12 +2,12 @@ from typing import TYPE_CHECKING -from polars.datatypes.constants import N_INFER_DEFAULT -from polars.series.utils import expr_dispatch -from polars.utils.deprecation import ( +from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, ) +from polars.datatypes.constants import N_INFER_DEFAULT +from polars.series.utils import expr_dispatch if TYPE_CHECKING: from polars import Expr, Series diff --git a/py-polars/polars/series/struct.py b/py-polars/polars/series/struct.py index b0fe9f4e22b9..2621876b9804 100644 --- a/py-polars/polars/series/struct.py +++ b/py-polars/polars/series/struct.py @@ -3,9 +3,9 @@ from collections import OrderedDict from typing import TYPE_CHECKING, Sequence +from polars._utils._wrap import wrap_df +from polars._utils.various import BUILDING_SPHINX_DOCS, sphinx_accessor from polars.series.utils import expr_dispatch -from polars.utils._wrap import wrap_df -from polars.utils.various import BUILDING_SPHINX_DOCS, sphinx_accessor if TYPE_CHECKING: from polars import DataFrame, DataType, Series diff --git a/py-polars/polars/series/utils.py b/py-polars/polars/series/utils.py index fb2f1440fb7a..e92ebb354f60 100644 --- a/py-polars/polars/series/utils.py +++ b/py-polars/polars/series/utils.py @@ -7,8 +7,8 @@ import polars._reexport as pl from polars import functions as F +from polars._utils._wrap import wrap_s from polars.datatypes import dtype_to_ffiname -from polars.utils._wrap import wrap_s if TYPE_CHECKING: from polars import Series diff --git a/py-polars/polars/sql/context.py b/py-polars/polars/sql/context.py index afbd1dcea4c1..acedf9a763e0 100644 --- a/py-polars/polars/sql/context.py +++ b/py-polars/polars/sql/context.py @@ -3,12 +3,12 @@ import contextlib from typing import TYPE_CHECKING, Collection, Generic, Mapping, overload +from polars._utils._wrap import wrap_ldf +from polars._utils.unstable import issue_unstable_warning +from polars._utils.various import _get_stack_locals from polars.dataframe import DataFrame from polars.lazyframe import LazyFrame from polars.type_aliases import FrameType -from polars.utils._wrap import wrap_ldf -from polars.utils.unstable import issue_unstable_warning -from polars.utils.various import _get_stack_locals with contextlib.suppress(ImportError): # Module not available when building docs from polars.polars import PySQLContext diff --git a/py-polars/polars/string_cache.py b/py-polars/polars/string_cache.py index dbf15d6244e8..6955d7da5e8e 100644 --- a/py-polars/polars/string_cache.py +++ b/py-polars/polars/string_cache.py @@ -3,7 +3,7 @@ import contextlib from typing import TYPE_CHECKING -from polars.utils.deprecation import issue_deprecation_warning +from polars._utils.deprecation import issue_deprecation_warning with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/testing/parametric/profiles.py b/py-polars/polars/testing/parametric/profiles.py index c1afda1c2bfe..76682af6d7f2 100644 --- a/py-polars/polars/testing/parametric/profiles.py +++ b/py-polars/polars/testing/parametric/profiles.py @@ -5,8 +5,8 @@ from hypothesis import settings +from polars._utils.deprecation import deprecate_nonkeyword_arguments from polars.type_aliases import ParametricProfileNames -from polars.utils.deprecation import deprecate_nonkeyword_arguments @deprecate_nonkeyword_arguments(allowed_args=["profile"], version="0.19.3") diff --git a/py-polars/tests/parametric/test_groupby_rolling.py b/py-polars/tests/parametric/test_groupby_rolling.py index ed7f0b5d513c..d6356167c7a8 100644 --- a/py-polars/tests/parametric/test_groupby_rolling.py +++ b/py-polars/tests/parametric/test_groupby_rolling.py @@ -8,10 +8,10 @@ from hypothesis import assume, given import polars as pl +from polars._utils.convert import parse_as_duration_string from polars.testing import assert_frame_equal from polars.testing.parametric.primitives import column, dataframes from polars.testing.parametric.strategies import strategy_closed, strategy_time_unit -from polars.utils.convert import parse_as_duration_string if TYPE_CHECKING: from polars.type_aliases import ClosedInterval, TimeUnit 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 bff14e5a461e..451ef3a2d848 100644 --- a/py-polars/tests/unit/constructors/test_any_value_fallbacks.py +++ b/py-polars/tests/unit/constructors/test_any_value_fallbacks.py @@ -8,8 +8,8 @@ import pytest import polars as pl +from polars._utils._wrap import wrap_s from polars.polars import PySeries -from polars.utils._wrap import wrap_s @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/constructors/test_constructors.py b/py-polars/tests/unit/constructors/test_constructors.py index ca57a8b6fa13..1cacd40703a5 100644 --- a/py-polars/tests/unit/constructors/test_constructors.py +++ b/py-polars/tests/unit/constructors/test_constructors.py @@ -13,11 +13,11 @@ from pydantic import BaseModel, Field, TypeAdapter import polars as pl +from polars._utils._construction import type_hints from polars.datatypes import PolarsDataType, numpy_char_code_to_dtype from polars.dependencies import dataclasses, pydantic from polars.exceptions import TimeZoneAwareConstructorWarning from polars.testing import assert_frame_equal, assert_series_equal -from polars.utils._construction import type_hints if TYPE_CHECKING: from collections.abc import Callable @@ -1461,7 +1461,7 @@ def test_nested_schema_construction2() -> None: def test_arrow_to_pyseries_with_one_chunk_does_not_copy_data() -> None: - from polars.utils._construction import arrow_to_pyseries + from polars._utils._construction import arrow_to_pyseries original_array = pa.chunked_array([[1, 2, 3]], type=pa.int64()) pyseries = arrow_to_pyseries("", original_array) diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 48f23f39152c..3fa78cb5e303 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -16,6 +16,7 @@ import polars as pl import polars.selectors as cs +from polars._utils._construction import iterable_to_pydf from polars.datatypes import DTYPE_TEMPORAL_UNITS, INTEGER_DTYPES from polars.exceptions import ComputeError, TimeZoneAwareConstructorWarning from polars.testing import ( @@ -24,7 +25,6 @@ assert_series_equal, ) from polars.testing.parametric import columns -from polars.utils._construction import iterable_to_pydf if TYPE_CHECKING: from zoneinfo import ZoneInfo diff --git a/py-polars/tests/unit/io/test_csv.py b/py-polars/tests/unit/io/test_csv.py index 70bce7dfe921..a940e26f3697 100644 --- a/py-polars/tests/unit/io/test_csv.py +++ b/py-polars/tests/unit/io/test_csv.py @@ -14,9 +14,9 @@ import zstandard import polars as pl +from polars._utils.various import normalize_filepath from polars.exceptions import ComputeError, NoDataError from polars.testing import assert_frame_equal, assert_series_equal -from polars.utils.various import normalize_filepath if TYPE_CHECKING: from pathlib import Path diff --git a/py-polars/tests/unit/operations/map/test_inefficient_map_warning.py b/py-polars/tests/unit/operations/map/test_inefficient_map_warning.py index a120c4076691..8f9740a42032 100644 --- a/py-polars/tests/unit/operations/map/test_inefficient_map_warning.py +++ b/py-polars/tests/unit/operations/map/test_inefficient_map_warning.py @@ -12,10 +12,10 @@ import pytest import polars as pl +from polars._utils.udfs import _NUMPY_FUNCTIONS, BytecodeParser +from polars._utils.various import in_terminal_that_supports_colour from polars.exceptions import PolarsInefficientMapWarning from polars.testing import assert_frame_equal, assert_series_equal -from polars.utils.udfs import _NUMPY_FUNCTIONS, BytecodeParser -from polars.utils.various import in_terminal_that_supports_colour MY_CONSTANT = 3 MY_DICT = {0: "a", 1: "b", 2: "c", 3: "d", 4: "e"} diff --git a/py-polars/tests/unit/operations/test_cast.py b/py-polars/tests/unit/operations/test_cast.py index 4040c112cb24..9c1cfdf1c47d 100644 --- a/py-polars/tests/unit/operations/test_cast.py +++ b/py-polars/tests/unit/operations/test_cast.py @@ -6,13 +6,13 @@ import pytest import polars as pl -from polars.testing import assert_frame_equal -from polars.testing.asserts.series import assert_series_equal -from polars.utils.convert import ( +from polars._utils.convert import ( MS_PER_SECOND, NS_PER_SECOND, US_PER_SECOND, ) +from polars.testing import assert_frame_equal +from polars.testing.asserts.series import assert_series_equal if TYPE_CHECKING: from polars import PolarsDataType diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index 8b48beb5edce..48238284c74b 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -11,6 +11,7 @@ import polars import polars as pl +from polars._utils._construction import iterable_to_pyseries from polars.datatypes import ( Date, Datetime, @@ -29,7 +30,6 @@ ) from polars.exceptions import ComputeError, PolarsInefficientMapWarning, ShapeError from polars.testing import assert_frame_equal, assert_series_equal -from polars.utils._construction import iterable_to_pyseries if TYPE_CHECKING: from zoneinfo import ZoneInfo diff --git a/py-polars/tests/unit/test_config.py b/py-polars/tests/unit/test_config.py index f4ed561a3b4e..f8efda2222b7 100644 --- a/py-polars/tests/unit/test_config.py +++ b/py-polars/tests/unit/test_config.py @@ -8,8 +8,8 @@ import polars as pl import polars.polars as plr +from polars._utils.unstable import issue_unstable_warning from polars.config import _POLARS_CFG_ENV_VARS -from polars.utils.unstable import issue_unstable_warning @pytest.fixture(autouse=True) diff --git a/py-polars/tests/unit/utils/test_deprecation.py b/py-polars/tests/unit/utils/test_deprecation.py index fee0a18724b6..2f42a0cd52bf 100644 --- a/py-polars/tests/unit/utils/test_deprecation.py +++ b/py-polars/tests/unit/utils/test_deprecation.py @@ -5,7 +5,7 @@ import pytest -from polars.utils.deprecation import ( +from polars._utils.deprecation import ( deprecate_function, deprecate_nonkeyword_arguments, deprecate_renamed_function, diff --git a/py-polars/tests/unit/utils/test_parse_expr_input.py b/py-polars/tests/unit/utils/test_parse_expr_input.py index 8c58c1307688..2f38b0e841b5 100644 --- a/py-polars/tests/unit/utils/test_parse_expr_input.py +++ b/py-polars/tests/unit/utils/test_parse_expr_input.py @@ -6,9 +6,9 @@ import pytest import polars as pl +from polars._utils._parse_expr_input import parse_as_expression +from polars._utils._wrap import wrap_expr from polars.testing import assert_frame_equal -from polars.utils._parse_expr_input import parse_as_expression -from polars.utils._wrap import wrap_expr def assert_expr_equal(result: pl.Expr, expected: pl.Expr) -> None: diff --git a/py-polars/tests/unit/utils/test_unstable.py b/py-polars/tests/unit/utils/test_unstable.py index ea9e5d594c9f..a760480a9a88 100644 --- a/py-polars/tests/unit/utils/test_unstable.py +++ b/py-polars/tests/unit/utils/test_unstable.py @@ -3,7 +3,7 @@ import pytest import polars as pl -from polars.utils.unstable import issue_unstable_warning, unstable +from polars._utils.unstable import issue_unstable_warning, unstable def test_issue_unstable_warning(monkeypatch: pytest.MonkeyPatch) -> None: diff --git a/py-polars/tests/unit/utils/test_utils.py b/py-polars/tests/unit/utils/test_utils.py index 352a1a3371e0..6ad359f6ec96 100644 --- a/py-polars/tests/unit/utils/test_utils.py +++ b/py-polars/tests/unit/utils/test_utils.py @@ -7,15 +7,14 @@ import pytest import polars as pl -from polars.io._utils import _looks_like_url -from polars.utils.convert import ( +from polars._utils.convert import ( date_to_int, datetime_to_int, parse_as_duration_string, time_to_int, timedelta_to_int, ) -from polars.utils.various import ( +from polars._utils.various import ( _in_notebook, is_bool_sequence, is_int_sequence, @@ -24,6 +23,7 @@ parse_percentiles, parse_version, ) +from polars.io._utils import _looks_like_url if TYPE_CHECKING: from zoneinfo import ZoneInfo From f4f50ceca3c4ba3541ac27d137100531628dc6c2 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 29 Feb 2024 14:07:00 +0100 Subject: [PATCH 2/5] Update reference --- crates/polars-lazy/src/physical_plan/executors/python_scan.rs | 2 +- py-polars/src/py_modules.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/polars-lazy/src/physical_plan/executors/python_scan.rs b/crates/polars-lazy/src/physical_plan/executors/python_scan.rs index 85ed618f79f0..1df5ad7861ef 100644 --- a/crates/polars-lazy/src/physical_plan/executors/python_scan.rs +++ b/crates/polars-lazy/src/physical_plan/executors/python_scan.rs @@ -21,7 +21,7 @@ impl Executor for PythonScanExec { let n_rows = self.options.n_rows.take(); Python::with_gil(|py| { let pl = PyModule::import(py, "polars").unwrap(); - let utils = pl.getattr("utils").unwrap(); + let utils = pl.getattr("_utils").unwrap(); let callable = utils.getattr("_execute_from_rust").unwrap(); let python_scan_function = self.options.scan_fn.take().unwrap().0; diff --git a/py-polars/src/py_modules.rs b/py-polars/src/py_modules.rs index 6c7dbd2658a1..7b0d37061349 100644 --- a/py-polars/src/py_modules.rs +++ b/py-polars/src/py_modules.rs @@ -5,7 +5,7 @@ pub(crate) static POLARS: Lazy = Lazy::new(|| Python::with_gil(|py| PyModule::import(py, "polars").unwrap().to_object(py))); pub(crate) static UTILS: Lazy = - Lazy::new(|| Python::with_gil(|py| POLARS.getattr(py, "utils").unwrap())); + Lazy::new(|| Python::with_gil(|py| POLARS.getattr(py, "_utils").unwrap())); pub(crate) static SERIES: Lazy = Lazy::new(|| Python::with_gil(|py| POLARS.getattr(py, "Series").unwrap())); From fd3af1858382def295dd5c1ab83ae13746f51750 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 29 Feb 2024 14:13:42 +0100 Subject: [PATCH 3/5] Update test references --- .github/scripts/test_bytecode_parser.py | 6 +++--- docs/user-guide/expressions/plugins.md | 2 +- py-polars/polars/dataframe/frame.py | 2 +- py-polars/tests/unit/constructors/test_constructors.py | 2 +- py-polars/tests/unit/dataframe/test_df.py | 2 +- py-polars/tests/unit/datatypes/test_temporal.py | 2 +- py-polars/tests/unit/expr/test_exprs.py | 2 +- .../tests/unit/functions/as_datatype/test_as_datatype.py | 2 +- py-polars/tests/unit/functions/range/test_datetime_range.py | 2 +- py-polars/tests/unit/namespaces/test_datetime.py | 2 +- py-polars/tests/unit/namespaces/test_strptime.py | 2 +- py-polars/tests/unit/operations/test_group_by_dynamic.py | 2 +- py-polars/tests/unit/series/test_series.py | 2 +- py-polars/tests/unit/utils/test_utils.py | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/scripts/test_bytecode_parser.py b/.github/scripts/test_bytecode_parser.py index 50073c1b0035..0fd65333cb7f 100644 --- a/.github/scripts/test_bytecode_parser.py +++ b/.github/scripts/test_bytecode_parser.py @@ -18,7 +18,7 @@ from typing import Any, Callable import pytest -from polars.utils.udfs import BytecodeParser +from polars._utils.udfs import BytecodeParser from tests.unit.operations.map.test_inefficient_map_warning import ( MY_DICT, NOOP_TEST_CASES, @@ -44,7 +44,7 @@ def test_bytecode_parser_expression_in_ipython( col: str, func: Callable[[Any], Any], expected: str ) -> None: script = ( - "from polars.utils.udfs import BytecodeParser; " + "from polars._utils.udfs import BytecodeParser; " "import datetime as dt; " "from datetime import datetime; " "import numpy as np; " @@ -73,7 +73,7 @@ def test_bytecode_parser_expression_noop(func: str) -> None: ) def test_bytecode_parser_expression_noop_in_ipython(func: str) -> None: script = ( - "from polars.utils.udfs import BytecodeParser; " + "from polars._utils.udfs import BytecodeParser; " f"MY_DICT = {MY_DICT};" f'parser = BytecodeParser({func}, map_target="expr");' f'print(not parser.can_attempt_rewrite() or not parser.to_expression("x"));' diff --git a/docs/user-guide/expressions/plugins.md b/docs/user-guide/expressions/plugins.md index 1f075650e975..22842e3e72a9 100644 --- a/docs/user-guide/expressions/plugins.md +++ b/docs/user-guide/expressions/plugins.md @@ -94,7 +94,7 @@ expression in batches. Whereas for other operations this would not be allowed, t # expression_lib/__init__.py import polars as pl from polars.type_aliases import IntoExpr -from polars.utils.udfs import _get_shared_lib_location +from polars._utils.udfs import _get_shared_lib_location from expression_lib.utils import parse_into_expr diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index ebfec171a83a..563bbc103880 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -6498,7 +6498,7 @@ def map_rows( >>> df.select(pl.col("foo") * 2 + pl.col("bar")) # doctest: +IGNORE_RESULT """ # TODO: Enable warning for inefficient map - # from polars.utils.udfs import warn_on_inefficient_map + # from polars._utils.udfs import warn_on_inefficient_map # warn_on_inefficient_map(function, columns=self.columns, map_target="frame) out, is_df = self._df.map_rows(function, return_dtype, inference_size) diff --git a/py-polars/tests/unit/constructors/test_constructors.py b/py-polars/tests/unit/constructors/test_constructors.py index 1cacd40703a5..c866f46a1558 100644 --- a/py-polars/tests/unit/constructors/test_constructors.py +++ b/py-polars/tests/unit/constructors/test_constructors.py @@ -26,7 +26,7 @@ from polars.datatypes import PolarsDataType else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo # ----------------------------------------------------------------------------------- diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 3fa78cb5e303..f77af5dbc6e4 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -31,7 +31,7 @@ from polars.type_aliases import JoinStrategy, UniqueKeepStrategy else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_version() -> None: diff --git a/py-polars/tests/unit/datatypes/test_temporal.py b/py-polars/tests/unit/datatypes/test_temporal.py index e3af046ad233..7f78dec6fb6e 100644 --- a/py-polars/tests/unit/datatypes/test_temporal.py +++ b/py-polars/tests/unit/datatypes/test_temporal.py @@ -28,7 +28,7 @@ from polars.type_aliases import Ambiguous, PolarsTemporalType, TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_fill_null() -> None: diff --git a/py-polars/tests/unit/expr/test_exprs.py b/py-polars/tests/unit/expr/test_exprs.py index fc5453035128..08ba41843495 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 else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_arg_true() -> None: diff --git a/py-polars/tests/unit/functions/as_datatype/test_as_datatype.py b/py-polars/tests/unit/functions/as_datatype/test_as_datatype.py index d0cafb850a61..2074865f694c 100644 --- a/py-polars/tests/unit/functions/as_datatype/test_as_datatype.py +++ b/py-polars/tests/unit/functions/as_datatype/test_as_datatype.py @@ -13,7 +13,7 @@ from polars.type_aliases import TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_date_datetime() -> 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 02150992d910..b9873f833b4b 100644 --- a/py-polars/tests/unit/functions/range/test_datetime_range.py +++ b/py-polars/tests/unit/functions/range/test_datetime_range.py @@ -16,7 +16,7 @@ from polars.datatypes import PolarsDataType from polars.type_aliases import ClosedInterval, TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_datetime_range() -> None: diff --git a/py-polars/tests/unit/namespaces/test_datetime.py b/py-polars/tests/unit/namespaces/test_datetime.py index 1f6fc9138581..70c75d3d1b84 100644 --- a/py-polars/tests/unit/namespaces/test_datetime.py +++ b/py-polars/tests/unit/namespaces/test_datetime.py @@ -15,7 +15,7 @@ from polars.type_aliases import TemporalLiteral, TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo @pytest.fixture() diff --git a/py-polars/tests/unit/namespaces/test_strptime.py b/py-polars/tests/unit/namespaces/test_strptime.py index 0d7a8fba8914..52d0fa4a61a3 100644 --- a/py-polars/tests/unit/namespaces/test_strptime.py +++ b/py-polars/tests/unit/namespaces/test_strptime.py @@ -20,7 +20,7 @@ from polars.type_aliases import PolarsTemporalType, TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_str_strptime() -> 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 bb3b5fa1f514..9fdcebfad510 100644 --- a/py-polars/tests/unit/operations/test_group_by_dynamic.py +++ b/py-polars/tests/unit/operations/test_group_by_dynamic.py @@ -14,7 +14,7 @@ from polars.type_aliases import Label, StartBy else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo @pytest.mark.parametrize( diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index 48238284c74b..8cc720a7fbfe 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -36,7 +36,7 @@ from polars.type_aliases import EpochTimeUnit, PolarsDataType, TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo def test_cum_agg() -> None: diff --git a/py-polars/tests/unit/utils/test_utils.py b/py-polars/tests/unit/utils/test_utils.py index 6ad359f6ec96..d81540efc10d 100644 --- a/py-polars/tests/unit/utils/test_utils.py +++ b/py-polars/tests/unit/utils/test_utils.py @@ -30,7 +30,7 @@ from polars.type_aliases import TimeUnit else: - from polars.utils.convert import string_to_zoneinfo as ZoneInfo + from polars._utils.convert import string_to_zoneinfo as ZoneInfo @pytest.mark.parametrize( From 5a3134da9781ddd2e4d764cdfdd2df41464ef770 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 29 Feb 2024 14:17:15 +0100 Subject: [PATCH 4/5] Remove underscores from submodules --- py-polars/polars/__init__.py | 4 ++-- py-polars/polars/_utils/__init__.py | 2 +- py-polars/polars/_utils/{_async.py => async_.py} | 2 +- .../_utils/{_construction.py => construction.py} | 2 +- .../{_parse_expr_input.py => parse_expr_input.py} | 0 .../_utils/{_polars_version.py => polars_version.py} | 0 py-polars/polars/_utils/{_scan.py => scan.py} | 0 py-polars/polars/_utils/{_wrap.py => wrap.py} | 0 py-polars/polars/dataframe/frame.py | 6 +++--- py-polars/polars/expr/array.py | 4 ++-- py-polars/polars/expr/binary.py | 4 ++-- py-polars/polars/expr/categorical.py | 2 +- py-polars/polars/expr/datetime.py | 4 ++-- py-polars/polars/expr/expr.py | 10 +++++----- py-polars/polars/expr/list.py | 4 ++-- py-polars/polars/expr/meta.py | 2 +- py-polars/polars/expr/string.py | 4 ++-- py-polars/polars/expr/struct.py | 2 +- py-polars/polars/expr/whenthen.py | 4 ++-- py-polars/polars/functions/aggregation/horizontal.py | 4 ++-- py-polars/polars/functions/as_datatype.py | 6 +++--- py-polars/polars/functions/col.py | 2 +- py-polars/polars/functions/eager.py | 2 +- py-polars/polars/functions/lazy.py | 12 ++++++------ py-polars/polars/functions/len.py | 2 +- py-polars/polars/functions/lit.py | 2 +- py-polars/polars/functions/range/date_range.py | 4 ++-- py-polars/polars/functions/range/datetime_range.py | 4 ++-- py-polars/polars/functions/range/int_range.py | 4 ++-- py-polars/polars/functions/range/time_range.py | 4 ++-- py-polars/polars/functions/repeat.py | 4 ++-- py-polars/polars/functions/whenthen.py | 2 +- py-polars/polars/io/csv/batched_reader.py | 2 +- py-polars/polars/lazyframe/frame.py | 12 ++++++------ py-polars/polars/lazyframe/group_by.py | 4 ++-- py-polars/polars/lazyframe/in_process.py | 2 +- py-polars/polars/meta/build.py | 2 +- py-polars/polars/meta/versions.py | 2 +- py-polars/polars/selectors.py | 2 +- py-polars/polars/series/array.py | 2 +- py-polars/polars/series/categorical.py | 2 +- py-polars/polars/series/datetime.py | 2 +- py-polars/polars/series/list.py | 2 +- py-polars/polars/series/series.py | 4 ++-- py-polars/polars/series/struct.py | 2 +- py-polars/polars/series/utils.py | 2 +- py-polars/polars/sql/context.py | 2 +- .../unit/constructors/test_any_value_fallbacks.py | 2 +- .../tests/unit/constructors/test_constructors.py | 4 ++-- py-polars/tests/unit/dataframe/test_df.py | 2 +- py-polars/tests/unit/series/test_series.py | 2 +- py-polars/tests/unit/utils/test_parse_expr_input.py | 4 ++-- 52 files changed, 83 insertions(+), 83 deletions(-) rename py-polars/polars/_utils/{_async.py => async_.py} (98%) rename py-polars/polars/_utils/{_construction.py => construction.py} (99%) rename py-polars/polars/_utils/{_parse_expr_input.py => parse_expr_input.py} (100%) rename py-polars/polars/_utils/{_polars_version.py => polars_version.py} (100%) rename py-polars/polars/_utils/{_scan.py => scan.py} (100%) rename py-polars/polars/_utils/{_wrap.py => wrap.py} (100%) diff --git a/py-polars/polars/__init__.py b/py-polars/polars/__init__.py index eb405fd370cb..dc958f9975fe 100644 --- a/py-polars/polars/__init__.py +++ b/py-polars/polars/__init__.py @@ -18,10 +18,10 @@ __register_startup_deps() from polars import api -from polars._utils._polars_version import get_polars_version as _get_polars_version +from polars._utils.polars_version import get_polars_version as _get_polars_version # TODO: remove need for importing wrap utils at top level -from polars._utils._wrap import wrap_df, wrap_s # noqa: F401 +from polars._utils.wrap import wrap_df, wrap_s # noqa: F401 from polars.config import Config from polars.convert import ( from_arrow, diff --git a/py-polars/polars/_utils/__init__.py b/py-polars/polars/_utils/__init__.py index 487583f45660..fbe278e8c7be 100644 --- a/py-polars/polars/_utils/__init__.py +++ b/py-polars/polars/_utils/__init__.py @@ -3,7 +3,6 @@ Functions that are part of the public API are re-exported here. """ -from polars._utils._scan import _execute_from_rust from polars._utils.convert import ( date_to_int, datetime_to_int, @@ -15,6 +14,7 @@ to_py_time, to_py_timedelta, ) +from polars._utils.scan import _execute_from_rust from polars._utils.various import NoDefault, _polars_warn, is_column, no_default __all__ = [ diff --git a/py-polars/polars/_utils/_async.py b/py-polars/polars/_utils/async_.py similarity index 98% rename from py-polars/polars/_utils/_async.py rename to py-polars/polars/_utils/async_.py index 9c90a5758d38..e90ae5d614ca 100644 --- a/py-polars/polars/_utils/_async.py +++ b/py-polars/polars/_utils/async_.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, Awaitable, Generator, Generic, TypeVar -from polars._utils._wrap import wrap_df +from polars._utils.wrap import wrap_df from polars.dependencies import _GEVENT_AVAILABLE if TYPE_CHECKING: diff --git a/py-polars/polars/_utils/_construction.py b/py-polars/polars/_utils/construction.py similarity index 99% rename from py-polars/polars/_utils/_construction.py rename to py-polars/polars/_utils/construction.py index f99e88a9b7ba..8c13cd2a2a97 100644 --- a/py-polars/polars/_utils/_construction.py +++ b/py-polars/polars/_utils/construction.py @@ -23,7 +23,6 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._wrap import wrap_df, wrap_s from polars._utils.various import ( _is_generator, arrlen, @@ -31,6 +30,7 @@ parse_version, range_to_series, ) +from polars._utils.wrap import wrap_df, wrap_s from polars.datatypes import ( INTEGER_DTYPES, N_INFER_DEFAULT, diff --git a/py-polars/polars/_utils/_parse_expr_input.py b/py-polars/polars/_utils/parse_expr_input.py similarity index 100% rename from py-polars/polars/_utils/_parse_expr_input.py rename to py-polars/polars/_utils/parse_expr_input.py diff --git a/py-polars/polars/_utils/_polars_version.py b/py-polars/polars/_utils/polars_version.py similarity index 100% rename from py-polars/polars/_utils/_polars_version.py rename to py-polars/polars/_utils/polars_version.py diff --git a/py-polars/polars/_utils/_scan.py b/py-polars/polars/_utils/scan.py similarity index 100% rename from py-polars/polars/_utils/_scan.py rename to py-polars/polars/_utils/scan.py diff --git a/py-polars/polars/_utils/_wrap.py b/py-polars/polars/_utils/wrap.py similarity index 100% rename from py-polars/polars/_utils/_wrap.py rename to py-polars/polars/_utils/wrap.py diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 563bbc103880..b78d05b109e0 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -31,7 +31,7 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._construction import ( +from polars._utils.construction import ( arrow_to_pydf, dict_to_pydf, frame_to_pydf, @@ -42,8 +42,6 @@ sequence_to_pydf, series_to_pydf, ) -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr, wrap_ldf, wrap_s from polars._utils.convert import parse_as_duration_string from polars._utils.deprecation import ( deprecate_function, @@ -54,6 +52,7 @@ deprecate_saturating, issue_deprecation_warning, ) +from polars._utils.parse_expr_input import parse_as_expression from polars._utils.unstable import issue_unstable_warning, unstable from polars._utils.various import ( _prepare_row_index_args, @@ -68,6 +67,7 @@ scale_bytes, warn_null_comparison, ) +from polars._utils.wrap import wrap_expr, wrap_ldf, wrap_s from polars.dataframe._html import NotebookFormatter from polars.dataframe.group_by import DynamicGroupBy, GroupBy, RollingGroupBy from polars.datatypes import ( diff --git a/py-polars/polars/expr/array.py b/py-polars/polars/expr/array.py index fcd8e2cab5ef..6972d5e1f062 100644 --- a/py-polars/polars/expr/array.py +++ b/py-polars/polars/expr/array.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING, Callable, Sequence -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr if TYPE_CHECKING: from datetime import date, datetime, time diff --git a/py-polars/polars/expr/binary.py b/py-polars/polars/expr/binary.py index 59aae759b7c1..978df94bb063 100644 --- a/py-polars/polars/expr/binary.py +++ b/py-polars/polars/expr/binary.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/categorical.py b/py-polars/polars/expr/categorical.py index 2ae258bf414e..ca00114c4e36 100644 --- a/py-polars/polars/expr/categorical.py +++ b/py-polars/polars/expr/categorical.py @@ -2,8 +2,8 @@ from typing import TYPE_CHECKING -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import deprecate_function +from polars._utils.wrap import wrap_expr if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/datetime.py b/py-polars/polars/expr/datetime.py index caf6b86f678d..09e76b5327bf 100644 --- a/py-polars/polars/expr/datetime.py +++ b/py-polars/polars/expr/datetime.py @@ -5,8 +5,6 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr from polars._utils.convert import parse_as_duration_string from polars._utils.deprecation import ( deprecate_function, @@ -15,7 +13,9 @@ issue_deprecation_warning, rename_use_earliest_to_ambiguous, ) +from polars._utils.parse_expr_input import parse_as_expression from polars._utils.unstable import unstable +from polars._utils.wrap import wrap_expr from polars.datatypes import DTYPE_TEMPORAL_UNITS, Date, Int32 if TYPE_CHECKING: diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index d5cb035464e4..71e8521b9764 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -25,11 +25,6 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._parse_expr_input import ( - parse_as_expression, - parse_as_list_of_expressions, - parse_predicates_constraints_as_expression, -) from polars._utils.convert import negate_duration_string, parse_as_duration_string from polars._utils.deprecation import ( deprecate_function, @@ -39,6 +34,11 @@ deprecate_saturating, issue_deprecation_warning, ) +from polars._utils.parse_expr_input import ( + parse_as_expression, + parse_as_list_of_expressions, + parse_predicates_constraints_as_expression, +) from polars._utils.unstable import issue_unstable_warning, unstable from polars._utils.various import ( BUILDING_SPHINX_DOCS, diff --git a/py-polars/polars/expr/list.py b/py-polars/polars/expr/list.py index d82ae599cf75..b81caf6d6113 100644 --- a/py-polars/polars/expr/list.py +++ b/py-polars/polars/expr/list.py @@ -5,12 +5,12 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, ) +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr if TYPE_CHECKING: from datetime import date, datetime, time diff --git a/py-polars/polars/expr/meta.py b/py-polars/polars/expr/meta.py index 03f4485a0f64..e4c008fecb41 100644 --- a/py-polars/polars/expr/meta.py +++ b/py-polars/polars/expr/meta.py @@ -4,12 +4,12 @@ from pathlib import Path from typing import TYPE_CHECKING, Literal, overload -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import ( deprecate_nonkeyword_arguments, deprecate_renamed_function, ) from polars._utils.various import normalize_filepath +from polars._utils.wrap import wrap_expr from polars.exceptions import ComputeError if TYPE_CHECKING: diff --git a/py-polars/polars/expr/string.py b/py-polars/polars/expr/string.py index d908b5f05b42..e00e555c0df7 100644 --- a/py-polars/polars/expr/string.py +++ b/py-polars/polars/expr/string.py @@ -5,15 +5,15 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, issue_deprecation_warning, rename_use_earliest_to_ambiguous, ) +from polars._utils.parse_expr_input import parse_as_expression from polars._utils.various import find_stacklevel +from polars._utils.wrap import wrap_expr from polars.datatypes import Date, Datetime, Int32, Time, py_type_to_dtype from polars.datatypes.constants import N_INFER_DEFAULT from polars.exceptions import ChronoFormatWarning diff --git a/py-polars/polars/expr/struct.py b/py-polars/polars/expr/struct.py index d2860469c4e3..709e9b8d16b1 100644 --- a/py-polars/polars/expr/struct.py +++ b/py-polars/polars/expr/struct.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Sequence -from polars._utils._wrap import wrap_expr +from polars._utils.wrap import wrap_expr if TYPE_CHECKING: from polars import Expr diff --git a/py-polars/polars/expr/whenthen.py b/py-polars/polars/expr/whenthen.py index 0bc7f683618f..c6e45f4520cf 100644 --- a/py-polars/polars/expr/whenthen.py +++ b/py-polars/polars/expr/whenthen.py @@ -3,11 +3,11 @@ from typing import TYPE_CHECKING, Any, Iterable import polars.functions as F -from polars._utils._parse_expr_input import ( +from polars._utils.parse_expr_input import ( parse_as_expression, parse_when_inputs, ) -from polars._utils._wrap import wrap_expr +from polars._utils.wrap import wrap_expr from polars.expr.expr import Expr if TYPE_CHECKING: diff --git a/py-polars/polars/functions/aggregation/horizontal.py b/py-polars/polars/functions/aggregation/horizontal.py index c3fe9cde4604..729a50d8de75 100644 --- a/py-polars/polars/functions/aggregation/horizontal.py +++ b/py-polars/polars/functions/aggregation/horizontal.py @@ -4,9 +4,9 @@ from typing import TYPE_CHECKING, Iterable import polars.functions as F -from polars._utils._parse_expr_input import parse_as_list_of_expressions -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import deprecate_renamed_function +from polars._utils.parse_expr_input import parse_as_list_of_expressions +from polars._utils.wrap import wrap_expr from polars.datatypes import UInt32 with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/as_datatype.py b/py-polars/polars/functions/as_datatype.py index f0c1ddd1a5ec..0e4af3ed2a08 100644 --- a/py-polars/polars/functions/as_datatype.py +++ b/py-polars/polars/functions/as_datatype.py @@ -4,12 +4,12 @@ from typing import TYPE_CHECKING, Iterable, overload from polars import functions as F -from polars._utils._parse_expr_input import ( +from polars._utils.deprecation import rename_use_earliest_to_ambiguous +from polars._utils.parse_expr_input import ( parse_as_expression, parse_as_list_of_expressions, ) -from polars._utils._wrap import wrap_expr -from polars._utils.deprecation import rename_use_earliest_to_ambiguous +from polars._utils.wrap import wrap_expr from polars.datatypes import Date, Struct, Time with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/col.py b/py-polars/polars/functions/col.py index 6ae8aa0ca421..ef2209c0ba41 100644 --- a/py-polars/polars/functions/col.py +++ b/py-polars/polars/functions/col.py @@ -3,7 +3,7 @@ import contextlib from typing import TYPE_CHECKING, Any, Iterable, Protocol, cast -from polars._utils._wrap import wrap_expr +from polars._utils.wrap import wrap_expr from polars.datatypes import is_polars_dtype plr: Any = None diff --git a/py-polars/polars/functions/eager.py b/py-polars/polars/functions/eager.py index 3b935fad15ad..dc47f8323dbd 100644 --- a/py-polars/polars/functions/eager.py +++ b/py-polars/polars/functions/eager.py @@ -7,8 +7,8 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._wrap import wrap_df, wrap_expr, wrap_ldf, wrap_s 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, FrameType diff --git a/py-polars/polars/functions/lazy.py b/py-polars/polars/functions/lazy.py index 9fcbbca3ef3e..308acb78f68c 100644 --- a/py-polars/polars/functions/lazy.py +++ b/py-polars/polars/functions/lazy.py @@ -5,18 +5,18 @@ import polars._reexport as pl import polars.functions as F -from polars._utils._async import _AioDataFrameResult, _GeventDataFrameResult -from polars._utils._parse_expr_input import ( - parse_as_expression, - parse_as_list_of_expressions, -) -from polars._utils._wrap import wrap_df, wrap_expr +from polars._utils.async_ import _AioDataFrameResult, _GeventDataFrameResult from polars._utils.deprecation import ( deprecate_parameter_as_positional, deprecate_renamed_function, issue_deprecation_warning, ) +from polars._utils.parse_expr_input import ( + parse_as_expression, + parse_as_list_of_expressions, +) from polars._utils.unstable import issue_unstable_warning, unstable +from polars._utils.wrap import wrap_df, wrap_expr from polars.datatypes import DTYPE_TEMPORAL_UNITS, Date, Datetime, Int64, UInt32 with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/len.py b/py-polars/polars/functions/len.py index fb4435e8d383..d731e5c16d54 100644 --- a/py-polars/polars/functions/len.py +++ b/py-polars/polars/functions/len.py @@ -8,7 +8,7 @@ import contextlib from typing import TYPE_CHECKING -from polars._utils._wrap import wrap_expr +from polars._utils.wrap import wrap_expr with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/functions/lit.py b/py-polars/polars/functions/lit.py index dd01013508ff..b636d5f2544a 100644 --- a/py-polars/polars/functions/lit.py +++ b/py-polars/polars/functions/lit.py @@ -5,13 +5,13 @@ from typing import TYPE_CHECKING, Any import polars._reexport as pl -from polars._utils._wrap import wrap_expr from polars._utils.convert import ( date_to_int, datetime_to_int, time_to_int, timedelta_to_int, ) +from polars._utils.wrap import wrap_expr from polars.datatypes import Date, Datetime, Duration, Time from polars.dependencies import _check_for_numpy from polars.dependencies import numpy as np diff --git a/py-polars/polars/functions/range/date_range.py b/py-polars/polars/functions/range/date_range.py index 91e1699129e6..918bffa53a4e 100644 --- a/py-polars/polars/functions/range/date_range.py +++ b/py-polars/polars/functions/range/date_range.py @@ -5,12 +5,12 @@ from typing import TYPE_CHECKING, overload from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import ( deprecate_saturating, issue_deprecation_warning, ) +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr from polars.functions.range._utils import parse_interval_argument with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/range/datetime_range.py b/py-polars/polars/functions/range/datetime_range.py index eafbbab9b92e..73a78042f668 100644 --- a/py-polars/polars/functions/range/datetime_range.py +++ b/py-polars/polars/functions/range/datetime_range.py @@ -4,9 +4,9 @@ from typing import TYPE_CHECKING, overload from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import deprecate_saturating +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr from polars.functions.range._utils import parse_interval_argument with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/range/int_range.py b/py-polars/polars/functions/range/int_range.py index f1c1c3fc6b04..0be6beeed3a6 100644 --- a/py-polars/polars/functions/range/int_range.py +++ b/py-polars/polars/functions/range/int_range.py @@ -4,8 +4,8 @@ from typing import TYPE_CHECKING, overload from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr, wrap_s +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr, wrap_s from polars.datatypes import Int64 with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/range/time_range.py b/py-polars/polars/functions/range/time_range.py index 54e0b01d62cf..bef7e8aef58c 100644 --- a/py-polars/polars/functions/range/time_range.py +++ b/py-polars/polars/functions/range/time_range.py @@ -5,9 +5,9 @@ from typing import TYPE_CHECKING, overload from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr from polars._utils.deprecation import deprecate_saturating +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr from polars.functions.range._utils import parse_interval_argument with contextlib.suppress(ImportError): # Module not available when building docs diff --git a/py-polars/polars/functions/repeat.py b/py-polars/polars/functions/repeat.py index b2d15c7fcff9..ae1dc413c1c1 100644 --- a/py-polars/polars/functions/repeat.py +++ b/py-polars/polars/functions/repeat.py @@ -6,8 +6,8 @@ from typing import TYPE_CHECKING, Any, overload from polars import functions as F -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr from polars.datatypes import ( FLOAT_DTYPES, INTEGER_DTYPES, diff --git a/py-polars/polars/functions/whenthen.py b/py-polars/polars/functions/whenthen.py index 091ad0a7d7a8..2c6254a346d3 100644 --- a/py-polars/polars/functions/whenthen.py +++ b/py-polars/polars/functions/whenthen.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Iterable import polars._reexport as pl -from polars._utils._parse_expr_input import parse_when_inputs +from polars._utils.parse_expr_input import parse_when_inputs with contextlib.suppress(ImportError): # Module not available when building docs import polars.polars as plr diff --git a/py-polars/polars/io/csv/batched_reader.py b/py-polars/polars/io/csv/batched_reader.py index 238a0dc8b35f..201b578be964 100644 --- a/py-polars/polars/io/csv/batched_reader.py +++ b/py-polars/polars/io/csv/batched_reader.py @@ -3,13 +3,13 @@ import contextlib from typing import TYPE_CHECKING, Sequence -from polars._utils._wrap import wrap_df from polars._utils.various import ( _prepare_row_index_args, _process_null_values, handle_projection_columns, normalize_filepath, ) +from polars._utils.wrap import wrap_df from polars.datatypes import N_INFER_DEFAULT, py_type_to_dtype from polars.io.csv._utils import _update_columns diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index a5f7c07d122d..01611c1a88db 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -24,12 +24,7 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._async import _AioDataFrameResult, _GeventDataFrameResult -from polars._utils._parse_expr_input import ( - parse_as_expression, - parse_as_list_of_expressions, -) -from polars._utils._wrap import wrap_df, wrap_expr +from polars._utils.async_ import _AioDataFrameResult, _GeventDataFrameResult from polars._utils.convert import negate_duration_string, parse_as_duration_string from polars._utils.deprecation import ( deprecate_function, @@ -39,6 +34,10 @@ deprecate_saturating, issue_deprecation_warning, ) +from polars._utils.parse_expr_input import ( + parse_as_expression, + parse_as_list_of_expressions, +) from polars._utils.unstable import issue_unstable_warning, unstable from polars._utils.various import ( _in_notebook, @@ -49,6 +48,7 @@ normalize_filepath, parse_percentiles, ) +from polars._utils.wrap import wrap_df, wrap_expr from polars.convert import from_dict from polars.datatypes import ( DTYPE_TEMPORAL_UNITS, diff --git a/py-polars/polars/lazyframe/group_by.py b/py-polars/polars/lazyframe/group_by.py index 74e54c69508f..72a9a8f22daa 100644 --- a/py-polars/polars/lazyframe/group_by.py +++ b/py-polars/polars/lazyframe/group_by.py @@ -3,9 +3,9 @@ from typing import TYPE_CHECKING, Callable, Iterable from polars import functions as F -from polars._utils._parse_expr_input import parse_as_list_of_expressions -from polars._utils._wrap import wrap_ldf from polars._utils.deprecation import deprecate_renamed_function +from polars._utils.parse_expr_input import parse_as_list_of_expressions +from polars._utils.wrap import wrap_ldf if TYPE_CHECKING: from polars import DataFrame, LazyFrame diff --git a/py-polars/polars/lazyframe/in_process.py b/py-polars/polars/lazyframe/in_process.py index e389ffb448c1..9bcee8dccfa0 100644 --- a/py-polars/polars/lazyframe/in_process.py +++ b/py-polars/polars/lazyframe/in_process.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING -from polars._utils._wrap import wrap_df +from polars._utils.wrap import wrap_df if TYPE_CHECKING: from polars import DataFrame diff --git a/py-polars/polars/meta/build.py b/py-polars/polars/meta/build.py index 191f2544f32a..4b6abcf5fcf9 100644 --- a/py-polars/polars/meta/build.py +++ b/py-polars/polars/meta/build.py @@ -2,7 +2,7 @@ from typing import Any -from polars._utils._polars_version import get_polars_version +from polars._utils.polars_version import get_polars_version try: from polars.polars import __build__ diff --git a/py-polars/polars/meta/versions.py b/py-polars/polars/meta/versions.py index 53bac57cd390..e2cfaba48e60 100644 --- a/py-polars/polars/meta/versions.py +++ b/py-polars/polars/meta/versions.py @@ -2,7 +2,7 @@ import sys -from polars._utils._polars_version import get_polars_version +from polars._utils.polars_version import get_polars_version from polars.meta.index_type import get_index_type diff --git a/py-polars/polars/selectors.py b/py-polars/polars/selectors.py index 80299436e007..ac552dc2e0b7 100644 --- a/py-polars/polars/selectors.py +++ b/py-polars/polars/selectors.py @@ -7,8 +7,8 @@ from typing import TYPE_CHECKING, Any, Collection, Literal, Mapping, overload from polars import functions as F -from polars._utils._parse_expr_input import _parse_inputs_as_iterable from polars._utils.deprecation import deprecate_nonkeyword_arguments +from polars._utils.parse_expr_input import _parse_inputs_as_iterable from polars._utils.various import is_column from polars.datatypes import ( FLOAT_DTYPES, diff --git a/py-polars/polars/series/array.py b/py-polars/polars/series/array.py index 42111049ae1c..04c88f701575 100644 --- a/py-polars/polars/series/array.py +++ b/py-polars/polars/series/array.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Sequence from polars import functions as F -from polars._utils._wrap import wrap_s +from polars._utils.wrap import wrap_s from polars.series.utils import expr_dispatch if TYPE_CHECKING: diff --git a/py-polars/polars/series/categorical.py b/py-polars/polars/series/categorical.py index 92ea54447b5e..204a125853a9 100644 --- a/py-polars/polars/series/categorical.py +++ b/py-polars/polars/series/categorical.py @@ -2,9 +2,9 @@ from typing import TYPE_CHECKING -from polars._utils._wrap import wrap_s from polars._utils.deprecation import deprecate_function from polars._utils.unstable import unstable +from polars._utils.wrap import wrap_s from polars.series.utils import expr_dispatch if TYPE_CHECKING: diff --git a/py-polars/polars/series/datetime.py b/py-polars/polars/series/datetime.py index dab5ff81db28..2a8628b2e94c 100644 --- a/py-polars/polars/series/datetime.py +++ b/py-polars/polars/series/datetime.py @@ -2,10 +2,10 @@ from typing import TYPE_CHECKING -from polars._utils._wrap import wrap_s from polars._utils.convert import to_py_date, to_py_datetime from polars._utils.deprecation import deprecate_function, deprecate_renamed_function from polars._utils.unstable import unstable +from polars._utils.wrap import wrap_s from polars.datatypes import Date, Datetime, Duration from polars.series.utils import expr_dispatch diff --git a/py-polars/polars/series/list.py b/py-polars/polars/series/list.py index 787dfa8fc617..ca89c0ceea2d 100644 --- a/py-polars/polars/series/list.py +++ b/py-polars/polars/series/list.py @@ -3,11 +3,11 @@ from typing import TYPE_CHECKING, Any, Callable, Sequence from polars import functions as F -from polars._utils._wrap import wrap_s from polars._utils.deprecation import ( deprecate_renamed_function, deprecate_renamed_parameter, ) +from polars._utils.wrap import wrap_s from polars.series.utils import expr_dispatch if TYPE_CHECKING: diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index 2935ad4f5b74..36af2fd1c70b 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -22,7 +22,7 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._construction import ( +from polars._utils.construction import ( arrow_to_pyseries, dataframe_to_pyseries, iterable_to_pyseries, @@ -32,7 +32,6 @@ sequence_to_pyseries, series_to_pyseries, ) -from polars._utils._wrap import wrap_df from polars._utils.convert import ( date_to_int, datetime_to_int, @@ -57,6 +56,7 @@ sphinx_accessor, warn_null_comparison, ) +from polars._utils.wrap import wrap_df from polars.datatypes import ( Array, Boolean, diff --git a/py-polars/polars/series/struct.py b/py-polars/polars/series/struct.py index 2621876b9804..3d95f2109c4c 100644 --- a/py-polars/polars/series/struct.py +++ b/py-polars/polars/series/struct.py @@ -3,8 +3,8 @@ from collections import OrderedDict from typing import TYPE_CHECKING, Sequence -from polars._utils._wrap import wrap_df from polars._utils.various import BUILDING_SPHINX_DOCS, sphinx_accessor +from polars._utils.wrap import wrap_df from polars.series.utils import expr_dispatch if TYPE_CHECKING: diff --git a/py-polars/polars/series/utils.py b/py-polars/polars/series/utils.py index e92ebb354f60..237b55a396da 100644 --- a/py-polars/polars/series/utils.py +++ b/py-polars/polars/series/utils.py @@ -7,7 +7,7 @@ import polars._reexport as pl from polars import functions as F -from polars._utils._wrap import wrap_s +from polars._utils.wrap import wrap_s from polars.datatypes import dtype_to_ffiname if TYPE_CHECKING: diff --git a/py-polars/polars/sql/context.py b/py-polars/polars/sql/context.py index acedf9a763e0..a7129091cb63 100644 --- a/py-polars/polars/sql/context.py +++ b/py-polars/polars/sql/context.py @@ -3,9 +3,9 @@ import contextlib from typing import TYPE_CHECKING, Collection, Generic, Mapping, overload -from polars._utils._wrap import wrap_ldf from polars._utils.unstable import issue_unstable_warning from polars._utils.various import _get_stack_locals +from polars._utils.wrap import wrap_ldf from polars.dataframe import DataFrame from polars.lazyframe import LazyFrame from polars.type_aliases import FrameType 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 451ef3a2d848..e98072fbf07d 100644 --- a/py-polars/tests/unit/constructors/test_any_value_fallbacks.py +++ b/py-polars/tests/unit/constructors/test_any_value_fallbacks.py @@ -8,7 +8,7 @@ import pytest import polars as pl -from polars._utils._wrap import wrap_s +from polars._utils.wrap import wrap_s from polars.polars import PySeries diff --git a/py-polars/tests/unit/constructors/test_constructors.py b/py-polars/tests/unit/constructors/test_constructors.py index c866f46a1558..7cdeb7ce90e2 100644 --- a/py-polars/tests/unit/constructors/test_constructors.py +++ b/py-polars/tests/unit/constructors/test_constructors.py @@ -13,7 +13,7 @@ from pydantic import BaseModel, Field, TypeAdapter import polars as pl -from polars._utils._construction import type_hints +from polars._utils.construction import type_hints from polars.datatypes import PolarsDataType, numpy_char_code_to_dtype from polars.dependencies import dataclasses, pydantic from polars.exceptions import TimeZoneAwareConstructorWarning @@ -1461,7 +1461,7 @@ def test_nested_schema_construction2() -> None: def test_arrow_to_pyseries_with_one_chunk_does_not_copy_data() -> None: - from polars._utils._construction import arrow_to_pyseries + from polars._utils.construction import arrow_to_pyseries original_array = pa.chunked_array([[1, 2, 3]], type=pa.int64()) pyseries = arrow_to_pyseries("", original_array) diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index f77af5dbc6e4..1063739e7797 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -16,7 +16,7 @@ import polars as pl import polars.selectors as cs -from polars._utils._construction import iterable_to_pydf +from polars._utils.construction import iterable_to_pydf from polars.datatypes import DTYPE_TEMPORAL_UNITS, INTEGER_DTYPES from polars.exceptions import ComputeError, TimeZoneAwareConstructorWarning from polars.testing import ( diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index 8cc720a7fbfe..5f48a3347711 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -11,7 +11,7 @@ import polars import polars as pl -from polars._utils._construction import iterable_to_pyseries +from polars._utils.construction import iterable_to_pyseries from polars.datatypes import ( Date, Datetime, diff --git a/py-polars/tests/unit/utils/test_parse_expr_input.py b/py-polars/tests/unit/utils/test_parse_expr_input.py index 2f38b0e841b5..a17debfc94cb 100644 --- a/py-polars/tests/unit/utils/test_parse_expr_input.py +++ b/py-polars/tests/unit/utils/test_parse_expr_input.py @@ -6,8 +6,8 @@ import pytest import polars as pl -from polars._utils._parse_expr_input import parse_as_expression -from polars._utils._wrap import wrap_expr +from polars._utils.parse_expr_input import parse_as_expression +from polars._utils.wrap import wrap_expr from polars.testing import assert_frame_equal From dccec103b63839d71663bf5bdccc92f38002927f Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 29 Feb 2024 16:08:40 +0100 Subject: [PATCH 5/5] Keep existing plugin utils for now --- docs/user-guide/expressions/plugins.md | 2 +- py-polars/polars/_utils/udfs.py | 15 +-------------- py-polars/polars/utils/__init__.py | 1 + py-polars/polars/utils/udfs.py | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 py-polars/polars/utils/__init__.py create mode 100644 py-polars/polars/utils/udfs.py diff --git a/docs/user-guide/expressions/plugins.md b/docs/user-guide/expressions/plugins.md index 22842e3e72a9..1f075650e975 100644 --- a/docs/user-guide/expressions/plugins.md +++ b/docs/user-guide/expressions/plugins.md @@ -94,7 +94,7 @@ expression in batches. Whereas for other operations this would not be allowed, t # expression_lib/__init__.py import polars as pl from polars.type_aliases import IntoExpr -from polars._utils.udfs import _get_shared_lib_location +from polars.utils.udfs import _get_shared_lib_location from expression_lib.utils import parse_into_expr diff --git a/py-polars/polars/_utils/udfs.py b/py-polars/polars/_utils/udfs.py index 3cf27d1a7e07..e0450b3b4d89 100644 --- a/py-polars/polars/_utils/udfs.py +++ b/py-polars/polars/_utils/udfs.py @@ -977,17 +977,4 @@ def warn_on_inefficient_map( ) -def is_shared_lib(file: str) -> bool: - return file.endswith((".so", ".dll", ".pyd")) - - -def _get_shared_lib_location(main_file: Any) -> str: - import os - - directory = os.path.dirname(main_file) # noqa: PTH120 - return os.path.join( # noqa: PTH118 - directory, next(filter(is_shared_lib, os.listdir(directory))) - ) - - -__all__ = ["BytecodeParser", "warn_on_inefficient_map", "_get_shared_lib_location"] +__all__ = ["BytecodeParser", "warn_on_inefficient_map"] diff --git a/py-polars/polars/utils/__init__.py b/py-polars/polars/utils/__init__.py new file mode 100644 index 000000000000..6efa5aaa60c0 --- /dev/null +++ b/py-polars/polars/utils/__init__.py @@ -0,0 +1 @@ +"""Deprecated module. Do not use.""" diff --git a/py-polars/polars/utils/udfs.py b/py-polars/polars/utils/udfs.py new file mode 100644 index 000000000000..398197ecef1a --- /dev/null +++ b/py-polars/polars/utils/udfs.py @@ -0,0 +1,17 @@ +"""Deprecated module. Do not use.""" + +import os +from typing import Any + +__all__ = ["_get_shared_lib_location"] + + +def _get_shared_lib_location(main_file: Any) -> str: + directory = os.path.dirname(main_file) # noqa: PTH120 + return os.path.join( # noqa: PTH118 + directory, next(filter(_is_shared_lib, os.listdir(directory))) + ) + + +def _is_shared_lib(file: str) -> bool: + return file.endswith((".so", ".dll", ".pyd"))