Skip to content

Commit 25e72c3

Browse files
authored
Redundant unions (#342)
* Revert "TYP: de-duplicate some type unions (#341)" This reverts commit f54d5ed. * disable flake8-pyi's Y041 * int + float * mypy * pyright and mypy need ignore comments at different lines * typing -> type
1 parent a560754 commit 25e72c3

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repos:
3030
- flake8-pyi==22.8.2
3131
types: [pyi]
3232
args: [
33-
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y026 Y027 Y034 Y037,
33+
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y026 Y027 Y034 Y037 Y041,
3434
# TypeVars in private files are already private
3535
--per-file-ignores=_*.pyi:Y001
3636
]

pandas-stubs/_typing.pyi

+7-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ PandasScalar = Union[bytes, datetime.date, datetime.datetime, datetime.timedelta
5353
DatetimeLike = Union[datetime.date, datetime.datetime, np.datetime64, Timestamp]
5454

5555
# dtypes
56-
NpDtype = Union[str, np.dtype[np.generic], type[object]]
56+
NpDtype = Union[str, np.dtype[np.generic], type[Union[str, complex, bool, object]]]
5757
Dtype = Union[ExtensionDtype, NpDtype]
5858
AstypeArg = Union[ExtensionDtype, npt.DTypeLike]
5959
# DtypeArg specifies all allowable dtypes in a functions its dtype argument
@@ -135,8 +135,14 @@ Scalar = Union[
135135
str,
136136
bytes,
137137
datetime.date,
138+
datetime.datetime,
138139
datetime.timedelta,
140+
bool,
141+
int,
142+
float,
139143
complex,
144+
Timestamp,
145+
Timedelta,
140146
]
141147
ScalarT = TypeVar("ScalarT", bound=Scalar)
142148
# Refine the definitions below in 3.9 to use the specialized type.

pandas-stubs/core/groupby/generic.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ class _DataFrameGroupByNonScalar(DataFrameGroupBy):
141141
class DataFrameGroupBy(GroupBy):
142142
def any(self, skipna: bool = ...) -> DataFrame: ...
143143
def all(self, skipna: bool = ...) -> DataFrame: ...
144+
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
144145
@overload
145-
def apply(
146+
def apply( # type: ignore[misc]
146147
self, func: Callable[[DataFrame], Scalar | list | dict], *args, **kwargs
147148
) -> Series: ...
148149
@overload
149150
def apply(
150151
self, func: Callable[[DataFrame], Series | DataFrame], *args, **kwargs
151152
) -> DataFrame: ...
152-
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
153153
@overload
154154
def apply( # pyright: ignore[reportOverlappingOverload]
155155
self, func: Callable[[Iterable], float], *args, **kwargs

0 commit comments

Comments
 (0)