Skip to content

Commit 4cf6867

Browse files
authored
Revert "TYP: Many typing constructs are invariant" (#46530)
This reverts commit fcab848.
1 parent fcab848 commit 4cf6867

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

pandas/_typing.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@
7474
npt: Any = None
7575

7676

77-
# Functions that take Dict/Mapping/List/Sequence/Callable can be tricky to type:
78-
# - keys of Dict and Mapping do not accept sub-classes
79-
# - items of List and Sequence do not accept sub-classes
80-
# - input argument to Callable cannot be sub-classes
81-
# If you want to allow any type and it's sub-classes in the above cases, you can
82-
# use TypeVar("AllowsSubclasses", bound=class)
83-
HashableT = TypeVar("HashableT", bound=Hashable)
84-
8577
# array-like
8678

8779
ArrayLike = Union["ExtensionArray", np.ndarray]
@@ -113,7 +105,7 @@
113105
NDFrameT = TypeVar("NDFrameT", bound="NDFrame")
114106

115107
Axis = Union[str, int]
116-
IndexLabel = Union[Hashable, Sequence[HashableT]]
108+
IndexLabel = Union[Hashable, Sequence[Hashable]]
117109
Level = Union[Hashable, int]
118110
Shape = Tuple[int, ...]
119111
Suffixes = Tuple[Optional[str], Optional[str]]
@@ -135,19 +127,19 @@
135127
Dtype = Union["ExtensionDtype", NpDtype]
136128
AstypeArg = Union["ExtensionDtype", "npt.DTypeLike"]
137129
# DtypeArg specifies all allowable dtypes in a functions its dtype argument
138-
DtypeArg = Union[Dtype, Dict[HashableT, Dtype]]
130+
DtypeArg = Union[Dtype, Dict[Hashable, Dtype]]
139131
DtypeObj = Union[np.dtype, "ExtensionDtype"]
140132

141133
# converters
142-
ConvertersArg = Dict[HashableT, Callable[[Dtype], Dtype]]
134+
ConvertersArg = Dict[Hashable, Callable[[Dtype], Dtype]]
143135

144136
# parse_dates
145137
ParseDatesArg = Union[
146-
bool, List[HashableT], List[List[HashableT]], Dict[HashableT, List[Hashable]]
138+
bool, List[Hashable], List[List[Hashable]], Dict[Hashable, List[Hashable]]
147139
]
148140

149141
# For functions like rename that convert one label to another
150-
Renamer = Union[Mapping[HashableT, Any], Callable[[HashableT], Hashable]]
142+
Renamer = Union[Mapping[Hashable, Any], Callable[[Hashable], Hashable]]
151143

152144
# to maintain type information across generic functions and parametrization
153145
T = TypeVar("T")
@@ -164,7 +156,7 @@
164156

165157
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
166158
AggFuncTypeBase = Union[Callable, str]
167-
AggFuncTypeDict = Dict[HashableT, Union[AggFuncTypeBase, List[AggFuncTypeBase]]]
159+
AggFuncTypeDict = Dict[Hashable, Union[AggFuncTypeBase, List[AggFuncTypeBase]]]
168160
AggFuncType = Union[
169161
AggFuncTypeBase,
170162
List[AggFuncTypeBase],
@@ -268,10 +260,10 @@ def closed(self) -> bool:
268260
FormattersType = Union[
269261
List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable]
270262
]
271-
ColspaceType = Mapping[HashableT, Union[str, int]]
263+
ColspaceType = Mapping[Hashable, Union[str, int]]
272264
FloatFormatType = Union[str, Callable, "EngFormatter"]
273265
ColspaceArgType = Union[
274-
str, int, Sequence[Union[str, int]], Mapping[HashableT, Union[str, int]]
266+
str, int, Sequence[Union[str, int]], Mapping[Hashable, Union[str, int]]
275267
]
276268

277269
# Arguments for fillna()

0 commit comments

Comments
 (0)