From 4edd7ee5d8f7a86e97ddf4077d6cf7c61a176d81 Mon Sep 17 00:00:00 2001 From: Anatoly Myachev Date: Sun, 12 May 2024 15:54:36 +0200 Subject: [PATCH] fixes Signed-off-by: Anatoly Myachev --- environment-dev.yml | 1 + modin/pandas/base.py | 29 +++++++------------------ modin/pandas/dataframe.py | 4 +--- modin/pandas/series.py | 2 +- requirements-dev.txt | 1 + requirements/env_hdk.yml | 1 + requirements/env_unidist_linux.yml | 1 + requirements/env_unidist_win.yml | 1 + requirements/requirements-no-engine.yml | 1 + 9 files changed, 16 insertions(+), 25 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 869e805b424..bb9b0ff8797 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -50,6 +50,7 @@ dependencies: - pytest-benchmark>=4.0.0 - pytest-cov>=4.0.0 - pytest-xdist>=3.2.0 + - typing_extensions # code linters - black>=24.1.0 diff --git a/modin/pandas/base.py b/modin/pandas/base.py index 00d5e1b0f25..7861ad165a6 100644 --- a/modin/pandas/base.py +++ b/modin/pandas/base.py @@ -20,16 +20,7 @@ import re import warnings from functools import cached_property -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Hashable, - Literal, - Optional, - Sequence, - Union, -) +from typing import TYPE_CHECKING, Any, Callable, Hashable, Literal, Optional, Sequence import numpy as np import pandas @@ -851,9 +842,7 @@ def align( ) @abc.abstractmethod - def _reduce_dimension( - self, query_compiler: BaseQueryCompiler - ) -> Union[Series, Scalar]: + def _reduce_dimension(self, query_compiler: BaseQueryCompiler) -> Series | Scalar: """ Reduce the dimension of data from the `query_compiler`. @@ -864,7 +853,7 @@ def _reduce_dimension( Returns ------- - Union[Series, Scalar] + Series | Scalar """ pass @@ -2019,12 +2008,10 @@ def iloc(self) -> _iLocIndexer: # noqa: RT01, D200 return _iLocIndexer(self) @_inherit_docstrings(pandas.DataFrame.kurt, apilink="pandas.DataFrame.kurt") - def kurt( - self, axis=0, skipna=True, numeric_only=False, **kwargs - ) -> Series | Scalar: + def kurt(self, axis=0, skipna=True, numeric_only=False, **kwargs) -> Series | float: return self._stat_operation("kurt", axis, skipna, numeric_only, **kwargs) - kurtosis: Series | Scalar = kurt + kurtosis: Series | float = kurt def last(self, offset) -> Self: # noqa: PR01, RT01, D200 """ @@ -2159,7 +2146,7 @@ def min( def _stat_operation( self, op_name: str, - axis: Union[int, str], + axis: int | str, skipna: bool, numeric_only: Optional[bool] = False, **kwargs, @@ -2279,7 +2266,7 @@ def notna(self) -> Self: # noqa: RT01, D200 notnull: Self = notna - def nunique(self, axis=0, dropna=True) -> Series | Scalar: # noqa: PR01, RT01, D200 + def nunique(self, axis=0, dropna=True) -> Series | int: # noqa: PR01, RT01, D200 """ Return number of unique elements in the `BasePandasDataset`. """ @@ -2599,7 +2586,7 @@ def resample( kind: Optional[str] = lib.no_default, on: Level = None, level: Level = None, - origin: Union[str, TimestampConvertibleTypes] = "start_day", + origin: str | TimestampConvertibleTypes = "start_day", offset: Optional[TimedeltaConvertibleTypes] = None, group_keys=False, ) -> Resampler: # noqa: PR01, RT01, D200 diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py index a2aad9c8228..1cf927a2c07 100644 --- a/modin/pandas/dataframe.py +++ b/modin/pandas/dataframe.py @@ -3157,9 +3157,7 @@ def _validate_eval_query(self, expr, **kwargs) -> None: "'Not' nodes are not implemented." ) # pragma: no cover - def _reduce_dimension( - self, query_compiler: BaseQueryCompiler - ) -> Union[Series, Scalar]: + def _reduce_dimension(self, query_compiler: BaseQueryCompiler) -> Series: """ Reduce the dimension of data from the `query_compiler`. diff --git a/modin/pandas/series.py b/modin/pandas/series.py index d2039070b57..31d59d57fcc 100644 --- a/modin/pandas/series.py +++ b/modin/pandas/series.py @@ -2395,7 +2395,7 @@ def _qcut(self, q, **kwargs): # noqa: PR01, RT01, D200 """ return self._default_to_pandas(pandas.qcut, q, **kwargs) - def _reduce_dimension(self, query_compiler) -> Union[Series, Scalar]: + def _reduce_dimension(self, query_compiler) -> Series | Scalar: """ Try to reduce the dimension of data from the `query_compiler`. diff --git a/requirements-dev.txt b/requirements-dev.txt index 2e2a22df1a6..0a6e5c5fa33 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -52,6 +52,7 @@ pytest>=7.3.2 pytest-benchmark>=4.0.0 pytest-cov>=4.0.0 pytest-xdist>=3.2.0 +typing_extensions ## code linters black>=24.1.0 diff --git a/requirements/env_hdk.yml b/requirements/env_hdk.yml index 3c0d3ecc9f8..f36ddf03efe 100644 --- a/requirements/env_hdk.yml +++ b/requirements/env_hdk.yml @@ -34,6 +34,7 @@ dependencies: - pytest>=7.3.2 - pytest-cov>=4.0.0 - pytest-xdist>=3.2.0 + - typing_extensions # code linters - black>=24.1.0 diff --git a/requirements/env_unidist_linux.yml b/requirements/env_unidist_linux.yml index a6158a61886..4e6c7d90778 100644 --- a/requirements/env_unidist_linux.yml +++ b/requirements/env_unidist_linux.yml @@ -44,6 +44,7 @@ dependencies: - pytest>=7.3.2 - pytest-cov>=4.0.0 - pytest-xdist>=3.2.0 + - typing_extensions # code linters - black>=24.1.0 diff --git a/requirements/env_unidist_win.yml b/requirements/env_unidist_win.yml index bcab0a2ded4..b11e33c8a91 100644 --- a/requirements/env_unidist_win.yml +++ b/requirements/env_unidist_win.yml @@ -44,6 +44,7 @@ dependencies: - pytest>=7.3.2 - pytest-cov>=4.0.0 - pytest-xdist>=3.2.0 + - typing_extensions # code linters - black>=24.1.0 diff --git a/requirements/requirements-no-engine.yml b/requirements/requirements-no-engine.yml index ea23c020237..64738dbc75e 100644 --- a/requirements/requirements-no-engine.yml +++ b/requirements/requirements-no-engine.yml @@ -37,6 +37,7 @@ dependencies: - pytest>=7.3.2 - pytest-cov>=4.0.0 - pytest-xdist>=3.2.0 + - typing_extensions # code linters - black>=24.1.0