Skip to content

Commit b805290

Browse files
simonjayhawkinsTomAugspurger
authored andcommitted
update per comments
1 parent d6f01b8 commit b805290

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

pandas/_typing.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,27 @@
2525
from pandas.core.generic import NDFrame # noqa: F401
2626
from pandas import Interval # noqa: F401
2727

28+
# arrary-like
2829

2930
AnyArrayLike = TypeVar("AnyArrayLike", "ExtensionArray", "Index", "Series", np.ndarray)
3031
ArrayLike = TypeVar("ArrayLike", "ExtensionArray", np.ndarray)
31-
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta")
32-
Dtype = Union[str, np.dtype, "ExtensionDtype"]
33-
FilePathOrBuffer = Union[str, Path, IO[AnyStr]]
3432

35-
FrameOrSeries = TypeVar("FrameOrSeries", bound="NDFrame")
33+
# scalars
34+
3635
PythonScalar = Union[str, int, float, bool]
36+
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta")
3737
PandasScalar = Union[DatetimeLikeScalar, "Interval"]
3838
Scalar = Union[PythonScalar, PandasScalar]
39+
40+
# other
41+
42+
Dtype = Union[str, np.dtype, "ExtensionDtype"]
43+
FilePathOrBuffer = Union[str, Path, IO[AnyStr]]
44+
FrameOrSeries = TypeVar("FrameOrSeries", bound="NDFrame")
3945
Axis = Union[str, int]
4046
Ordered = Optional[bool]
4147
JSONSerializable = Union[PythonScalar, List, Dict]
42-
4348
Axes = Collection
4449

4550
# to maintain type information across generic functions and parametrization
46-
_T = TypeVar("_T")
51+
T = TypeVar("T")

pandas/core/common.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
from datetime import datetime, timedelta
1010
from functools import partial
1111
import inspect
12-
from typing import Any, Collection, Iterable, TypeVar, Union
12+
from typing import Any, Collection, Iterable, Union
1313

1414
import numpy as np
1515

1616
from pandas._libs import lib, tslibs
17+
from pandas._typing import T
1718

1819
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
1920
from pandas.core.dtypes.common import (
@@ -270,10 +271,7 @@ def maybe_make_list(obj):
270271
return obj
271272

272273

273-
_T = TypeVar("_T")
274-
275-
276-
def maybe_iterable_to_list(obj: Union[Iterable[_T], _T]) -> Union[Collection[_T], _T]:
274+
def maybe_iterable_to_list(obj: Union[Iterable[T], T]) -> Union[Collection[T], T]:
277275
"""
278276
If obj is Iterable but not list-like, consume into list.
279277
"""

0 commit comments

Comments
 (0)