Skip to content

Redundant unions #342

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 6 commits into from
Sep 30, 2022
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
- flake8-pyi==22.8.2
types: [pyi]
args: [
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y026 Y027 Y034 Y037,
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y026 Y027 Y034 Y037 Y041,
# TypeVars in private files are already private
--per-file-ignores=_*.pyi:Y001
]
8 changes: 7 additions & 1 deletion pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ PandasScalar = Union[bytes, datetime.date, datetime.datetime, datetime.timedelta
DatetimeLike = Union[datetime.date, datetime.datetime, np.datetime64, Timestamp]

# dtypes
NpDtype = Union[str, np.dtype[np.generic], type[object]]
NpDtype = Union[str, np.dtype[np.generic], type[Union[str, complex, bool, object]]]
Dtype = Union[ExtensionDtype, NpDtype]
AstypeArg = Union[ExtensionDtype, npt.DTypeLike]
# DtypeArg specifies all allowable dtypes in a functions its dtype argument
Expand Down Expand Up @@ -135,8 +135,14 @@ Scalar = Union[
str,
bytes,
datetime.date,
datetime.datetime,
datetime.timedelta,
bool,
int,
float,
complex,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we bring back int and float here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added ignore for

pandas-stubs/core/groupby/generic.pyi:145: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [misc]

that was hidden by python/mypy#13775

Timestamp,
Timedelta,
]
ScalarT = TypeVar("ScalarT", bound=Scalar)
# Refine the definitions below in 3.9 to use the specialized type.
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/groupby/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ class _DataFrameGroupByNonScalar(DataFrameGroupBy):
class DataFrameGroupBy(GroupBy):
def any(self, skipna: bool = ...) -> DataFrame: ...
def all(self, skipna: bool = ...) -> DataFrame: ...
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
@overload
def apply(
def apply( # type: ignore[misc]
self, func: Callable[[DataFrame], Scalar | list | dict], *args, **kwargs
) -> Series: ...
@overload
def apply(
self, func: Callable[[DataFrame], Series | DataFrame], *args, **kwargs
) -> DataFrame: ...
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
@overload
def apply( # pyright: ignore[reportOverlappingOverload]
self, func: Callable[[Iterable], float], *args, **kwargs
Expand Down