-
-
Notifications
You must be signed in to change notification settings - Fork 141
TYP: de-duplicate some type unions #341
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
Conversation
Lgtm. |
Should have maybe waited for more consensus on the mypy issue, luckily easy to revert :) |
Might also consider skipping flake8-pyi's check for |
I'm in favor of the redundancy, because it helps people understand what arguments are possible. Trying to help the novices, not just the experts like us! |
I also prefer redundancy, esp for int | float. |
This reverts commit f54d5ed.
Opened #342 to revert the change and disable the flake8-pyi check. Also opened a PR for the few pyi files in pandas itself. |
(flake8-pyi maintainer here) In case it's helpful: we deliberately excluded type aliases from Y041 on the grounds that redundant unions often serve valuable documentation purposes. So flake8-pyi will complain about this code: x: int | float But it deliberately won't complain about this code: from typing_extensions import TypeAlias
_IntOrFloat: TypeAlias = int | float
x: _IntOrFloat As such, you'll still find a few redundant unions in typeshed that have been deliberately left in, e.g. https://github.com/python/typeshed/blob/7576805aee96fe091821d4c963c46645a1894052/stdlib/fractions.pyi#L8 |
I think it did that manually :) |
This will avoid the new behavior/regression in mypy 0.981python/mypy#13760