Skip to content

STYLE: Enable ruff TCH on some files #51812

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 2 commits into from
Mar 7, 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
11 changes: 6 additions & 5 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@

from pandas._config import using_copy_on_write

from pandas._typing import (
Axis,
AxisInt,
HashableT,
)
from pandas.util._decorators import cache_readonly

from pandas.core.dtypes.concat import concat_compat
Expand Down Expand Up @@ -51,6 +46,12 @@
from pandas.core.internals import concatenate_managers

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

from pandas import (
DataFrame,
Series,
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/reshape/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from collections import defaultdict
import itertools
from typing import (
TYPE_CHECKING,
Hashable,
Iterable,
)

import numpy as np

from pandas._libs.sparse import IntIndex
from pandas._typing import NpDtype

from pandas.core.dtypes.common import (
is_integer_dtype,
Expand All @@ -28,6 +28,9 @@
)
from pandas.core.series import Series

if TYPE_CHECKING:
from pandas._typing import NpDtype


def get_dummies(
data,
Expand Down
13 changes: 7 additions & 6 deletions pandas/core/reshape/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
import numpy as np

from pandas._libs import lib
from pandas._typing import (
AggFuncType,
AggFuncTypeBase,
AggFuncTypeDict,
IndexLabel,
)
from pandas.util._decorators import (
Appender,
Substitution,
Expand Down Expand Up @@ -48,6 +42,13 @@
from pandas.core.series import Series

if TYPE_CHECKING:
from pandas._typing import (
AggFuncType,
AggFuncTypeBase,
AggFuncTypeDict,
IndexLabel,
)

from pandas import DataFrame


Expand Down
3 changes: 2 additions & 1 deletion pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import numpy as np

import pandas._libs.reshape as libreshape
from pandas._typing import npt
from pandas.errors import PerformanceWarning
from pandas.util._decorators import cache_readonly
from pandas.util._exceptions import find_stack_level
Expand Down Expand Up @@ -44,6 +43,8 @@
)

if TYPE_CHECKING:
from pandas._typing import npt

from pandas.core.arrays import ExtensionArray
from pandas.core.indexes.frozen import FrozenList

Expand Down
5 changes: 4 additions & 1 deletion pandas/core/reshape/tile.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,
Literal,
Expand All @@ -16,7 +17,6 @@
Timestamp,
)
from pandas._libs.lib import infer_dtype
from pandas._typing import IntervalLeftRight

from pandas.core.dtypes.common import (
DT64NS_DTYPE,
Expand Down Expand Up @@ -46,6 +46,9 @@
from pandas.core import nanops
import pandas.core.algorithms as algos

if TYPE_CHECKING:
from pandas._typing import IntervalLeftRight


def cut(
x,
Expand Down
7 changes: 5 additions & 2 deletions pandas/core/reshape/util.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from __future__ import annotations

import numpy as np
from typing import TYPE_CHECKING

from pandas._typing import NumpyIndexT
import numpy as np

from pandas.core.dtypes.common import is_list_like

if TYPE_CHECKING:
from pandas._typing import NumpyIndexT


def cartesian_product(X) -> list[np.ndarray]:
"""
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/strings/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import abc
import re
from typing import (
TYPE_CHECKING,
Callable,
Expand All @@ -10,9 +9,11 @@

import numpy as np

from pandas._typing import Scalar

if TYPE_CHECKING:
import re

from pandas._typing import Scalar

from pandas import Series


Expand Down
9 changes: 5 additions & 4 deletions pandas/core/strings/object_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
from pandas._libs import lib
import pandas._libs.missing as libmissing
import pandas._libs.ops as libops
from pandas._typing import (
NpDtype,
Scalar,
)

from pandas.core.dtypes.common import is_scalar
from pandas.core.dtypes.missing import isna

from pandas.core.strings.base import BaseStringArrayMethods

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

from pandas import Series


Expand Down
15 changes: 10 additions & 5 deletions pandas/core/tools/numeric.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import annotations

from typing import Literal
from typing import (
TYPE_CHECKING,
Literal,
)

import numpy as np

Expand All @@ -10,10 +13,6 @@
)

from pandas._libs import lib
from pandas._typing import (
DateTimeErrorChoices,
npt,
)

from pandas.core.dtypes.cast import maybe_downcast_numeric
from pandas.core.dtypes.common import (
Expand All @@ -36,6 +35,12 @@
import pandas as pd
from pandas.core.arrays import BaseMaskedArray

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


def to_numeric(
arg,
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/tools/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from datetime import timedelta
from typing import (
TYPE_CHECKING,
overload,
Expand All @@ -30,6 +29,8 @@
from pandas.core.arrays.timedeltas import sequence_to_td64ns

if TYPE_CHECKING:
from datetime import timedelta

from pandas._libs.tslibs.timedeltas import UnitChoices
from pandas._typing import (
ArrayLike,
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/tools/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
datetime,
time,
)
from typing import TYPE_CHECKING

import numpy as np

from pandas._libs.lib import is_list_like
from pandas._typing import DateTimeErrorChoices

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

if TYPE_CHECKING:
from pandas._typing import DateTimeErrorChoices


def to_time(
arg,
Expand Down
21 changes: 12 additions & 9 deletions pandas/core/window/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@

from pandas._libs.tslibs import Timedelta
import pandas._libs.window.aggregations as window_aggregations
from pandas._typing import (
Axis,
TimedeltaConvertibleTypes,
)

if TYPE_CHECKING:
from pandas import DataFrame, Series
from pandas.core.generic import NDFrame

from pandas.util._decorators import doc

from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -60,6 +51,18 @@
BaseWindowGroupby,
)

if TYPE_CHECKING:
from pandas._typing import (
Axis,
TimedeltaConvertibleTypes,
)

from pandas import (
DataFrame,
Series,
)
from pandas.core.generic import NDFrame


def get_center_of_mass(
comass: float | None,
Expand Down
23 changes: 13 additions & 10 deletions pandas/core/window/expanding.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
Callable,
)

from pandas._typing import (
Axis,
QuantileInterpolation,
WindowingRankType,
)

if TYPE_CHECKING:
from pandas import DataFrame, Series
from pandas.core.generic import NDFrame

from pandas.util._decorators import doc

from pandas.core.indexers.objects import (
Expand All @@ -40,6 +30,19 @@
RollingAndExpandingMixin,
)

if TYPE_CHECKING:
from pandas._typing import (
Axis,
QuantileInterpolation,
WindowingRankType,
)

from pandas import (
DataFrame,
Series,
)
from pandas.core.generic import NDFrame


class Expanding(RollingAndExpandingMixin):
"""
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/window/numba_.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

import numpy as np

from pandas._typing import Scalar
from pandas.compat._optional import import_optional_dependency

from pandas.core.util.numba_ import jit_user_function

if TYPE_CHECKING:
from pandas._typing import Scalar


@functools.lru_cache(maxsize=None)
def generate_numba_apply_func(
Expand Down
15 changes: 8 additions & 7 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
to_offset,
)
import pandas._libs.window.aggregations as window_aggregations
from pandas._typing import (
ArrayLike,
Axis,
NDFrameT,
QuantileInterpolation,
WindowingRankType,
)
from pandas.compat._optional import import_optional_dependency
from pandas.errors import DataError
from pandas.util._decorators import doc
Expand Down Expand Up @@ -99,6 +92,14 @@
)

if TYPE_CHECKING:
from pandas._typing import (
ArrayLike,
Axis,
NDFrameT,
QuantileInterpolation,
WindowingRankType,
)

from pandas import (
DataFrame,
Series,
Expand Down
3 changes: 2 additions & 1 deletion pandas/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: TCH004
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand All @@ -8,5 +9,5 @@
stata,
)

# and mark only those modules as public
# mark only those modules as public
__all__ = ["formats", "json", "stata"]
Loading