Skip to content

STYLE: Enable ruff TCH on some files #51781

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pandas/core/array_algos/masked_accumulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@

from __future__ import annotations

from typing import Callable
from typing import (
TYPE_CHECKING,
Callable,
)

import numpy as np

from pandas._typing import npt

from pandas.core.dtypes.common import (
is_bool_dtype,
is_float_dtype,
is_integer_dtype,
)

if TYPE_CHECKING:
from pandas._typing import npt


def _cum_func(
func: Callable,
Expand Down
15 changes: 10 additions & 5 deletions pandas/core/array_algos/masked_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
"""
from __future__ import annotations

from typing import Callable
from typing import (
TYPE_CHECKING,
Callable,
)

import numpy as np

from pandas._libs import missing as libmissing
from pandas._typing import (
AxisInt,
npt,
)

from pandas.core.nanops import check_below_min_count

if TYPE_CHECKING:
from pandas._typing import (
AxisInt,
npt,
)


def _reductions(
func: Callable,
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/array_algos/putmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
import numpy as np

from pandas._libs import lib
from pandas._typing import (
ArrayLike,
npt,
)
from pandas.compat import np_version_under1p21

from pandas.core.dtypes.cast import infer_dtype_from
Expand All @@ -23,6 +19,11 @@
from pandas.core.arrays import ExtensionArray

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
npt,
)

from pandas import MultiIndex


Expand Down
14 changes: 9 additions & 5 deletions pandas/core/array_algos/quantile.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np

from pandas._typing import (
ArrayLike,
Scalar,
npt,
)
from pandas.compat.numpy import np_percentile_argname

from pandas.core.dtypes.missing import (
isna,
na_value_for_dtype,
)

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
Scalar,
npt,
)


def quantile_compat(
values: ArrayLike, qs: npt.NDArray[np.float64], interpolation: str
Expand Down
14 changes: 8 additions & 6 deletions pandas/core/array_algos/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@
import operator
import re
from typing import (
TYPE_CHECKING,
Any,
Pattern,
)

import numpy as np

from pandas._typing import (
ArrayLike,
Scalar,
npt,
)

from pandas.core.dtypes.common import (
is_re,
is_re_compilable,
is_scalar,
)
from pandas.core.dtypes.missing import isna

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
Scalar,
npt,
)


def should_use_regex(regex: bool, to_replace: Any) -> bool:
"""
Expand Down
11 changes: 6 additions & 5 deletions pandas/core/array_algos/take.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
algos as libalgos,
lib,
)
from pandas._typing import (
ArrayLike,
AxisInt,
npt,
)

from pandas.core.dtypes.cast import maybe_promote
from pandas.core.dtypes.common import (
Expand All @@ -29,6 +24,12 @@
from pandas.core.construction import ensure_wrapped_if_datetimelike

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
AxisInt,
npt,
)

from pandas.core.arrays._mixins import NDArrayBackedExtensionArray
from pandas.core.arrays.base import ExtensionArray

Expand Down
5 changes: 4 additions & 1 deletion pandas/core/array_algos/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np

from pandas._typing import AxisInt
if TYPE_CHECKING:
from pandas._typing import AxisInt


def shift(values: np.ndarray, periods: int, axis: AxisInt, fill_value) -> np.ndarray:
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/dtypes/astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@

from pandas._libs import lib
from pandas._libs.tslibs.timedeltas import array_to_timedelta64
from pandas._typing import (
ArrayLike,
DtypeObj,
IgnoreRaise,
)
from pandas.errors import IntCastingNaNError

from pandas.core.dtypes.common import (
Expand All @@ -37,8 +32,13 @@
)

if TYPE_CHECKING:
from pandas.core.arrays import ExtensionArray
from pandas._typing import (
ArrayLike,
DtypeObj,
IgnoreRaise,
)

from pandas.core.arrays import ExtensionArray

_dtype_obj = np.dtype(object)

Expand Down
13 changes: 7 additions & 6 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

from pandas._libs import missing as libmissing
from pandas._libs.hashtable import object_hash
from pandas._typing import (
DtypeObj,
Shape,
npt,
type_t,
)
from pandas.errors import AbstractMethodError

from pandas.core.dtypes.generic import (
Expand All @@ -30,6 +24,13 @@
)

if TYPE_CHECKING:
from pandas._typing import (
DtypeObj,
Shape,
npt,
type_t,
)

from pandas.core.arrays import ExtensionArray

# To parameterize on same ExtensionDtype
Expand Down
17 changes: 9 additions & 8 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
is_supported_unit,
)
from pandas._libs.tslibs.timedeltas import array_to_timedelta64
from pandas._typing import (
ArrayLike,
Dtype,
DtypeObj,
NumpyIndexT,
Scalar,
npt,
)
from pandas.errors import (
IntCastingNaNError,
LossySetitemError,
Expand Down Expand Up @@ -100,6 +92,15 @@
)

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
Dtype,
DtypeObj,
NumpyIndexT,
Scalar,
npt,
)

from pandas import Index
from pandas.core.arrays import (
Categorical,
Expand Down
11 changes: 7 additions & 4 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

from typing import (
TYPE_CHECKING,
Any,
Callable,
)
Expand All @@ -17,10 +18,6 @@
lib,
)
from pandas._libs.tslibs import conversion
from pandas._typing import (
ArrayLike,
DtypeObj,
)

from pandas.core.dtypes.base import _registry as registry
from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -54,6 +51,12 @@
is_sequence,
)

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
DtypeObj,
)

DT64NS_DTYPE = conversion.DT64NS_DTYPE
TD64NS_DTYPE = conversion.TD64NS_DTYPE
INT64_DTYPE = np.dtype(np.int64)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/dtypes/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import numpy as np

from pandas._typing import AxisInt

from pandas.core.dtypes.astype import astype_array
from pandas.core.dtypes.cast import (
common_dtype_categorical_compat,
Expand All @@ -26,6 +24,8 @@
)

if TYPE_CHECKING:
from pandas._typing import AxisInt

from pandas.core.arrays import Categorical


Expand Down
15 changes: 8 additions & 7 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@
PeriodDtypeBase,
abbrev_to_npy_unit,
)
from pandas._typing import (
Dtype,
DtypeObj,
Ordered,
npt,
type_t,
)

from pandas.core.dtypes.base import (
ExtensionDtype,
Expand All @@ -57,6 +50,14 @@

import pyarrow

from pandas._typing import (
Dtype,
DtypeObj,
Ordered,
npt,
type_t,
)

from pandas import (
Categorical,
Index,
Expand Down
Loading