Skip to content

Enabled ruff TCH on some files #51827

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 8 commits into from
Mar 9, 2023
15 changes: 10 additions & 5 deletions pandas/core/ops/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import datetime
from functools import partial
import operator
from typing import Any
from typing import (
TYPE_CHECKING,
Any,
)

import numpy as np

Expand All @@ -19,10 +22,6 @@
ops as libops,
)
from pandas._libs.tslibs import BaseOffset
from pandas._typing import (
ArrayLike,
Shape,
)

from pandas.core.dtypes.cast import (
construct_1d_object_array_from_listlike,
Expand Down Expand Up @@ -54,6 +53,12 @@
from pandas.core.ops.dispatch import should_extension_dispatch
from pandas.core.ops.invalid import invalid_comparison

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

# -----------------------------------------------------------------------------
# Masking NA values and fallbacks for operations numpy does not support

Expand Down
9 changes: 7 additions & 2 deletions pandas/core/ops/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@

from functools import wraps
import sys
from typing import Callable
from typing import (
TYPE_CHECKING,
Callable,
)

from pandas._libs.lib import item_from_zerodim
from pandas._libs.missing import is_matching_na
from pandas._typing import F

from pandas.core.dtypes.generic import (
ABCDataFrame,
ABCIndex,
ABCSeries,
)

if TYPE_CHECKING:
from pandas._typing import F


def unpack_zerodim_and_defer(name: str) -> Callable[[F], F]:
"""
Expand Down
10 changes: 7 additions & 3 deletions pandas/core/ops/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
"""
from __future__ import annotations

from typing import Any

from pandas._typing import ArrayLike
from typing import (
TYPE_CHECKING,
Any,
)

from pandas.core.dtypes.generic import ABCExtensionArray

if TYPE_CHECKING:
from pandas._typing import ArrayLike


def should_extension_dispatch(left: ArrayLike, right: Any) -> bool:
"""
Expand Down
19 changes: 10 additions & 9 deletions pandas/core/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@
lib,
)
from pandas._libs.hashtable import unique_label_indices
from pandas._typing import (
AxisInt,
IndexKeyFunc,
Level,
NaPosition,
Shape,
SortKind,
npt,
)

from pandas.core.dtypes.common import (
ensure_int64,
Expand All @@ -44,6 +35,16 @@
from pandas.core.construction import extract_array

if TYPE_CHECKING:
from pandas._typing import (
AxisInt,
IndexKeyFunc,
Level,
NaPosition,
Shape,
SortKind,
npt,
)

from pandas import MultiIndex
from pandas.core.arrays import ExtensionArray
from pandas.core.indexes.base import Index
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ exclude = [
# TCH to be enabled gradually
"pandas/core/arrays/*" = ["TCH"]
"pandas/core/nanops.py" = ["TCH"]
"pandas/core/apply.py" = ["TCH"]
"pandas/core/base.py" = ["TCH"]
"pandas/core/algorithms.py" = ["TCH"]
"pandas/core/ops/*" = ["TCH"]
"pandas/core/sorting.py" = ["TCH"]
"pandas/util/*" = ["TCH"]
"pandas/_libs/*" = ["TCH"]
# Keep this one enabled
Expand Down