-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Recommend using PEP 585 #5055
Recommend using PEP 585 #5055
Conversation
Remove old note about optional default arguments (now part of PEP 484 and enforced by CI)
Weird that the pytype check fails here, while it succeeded in #5050. |
CONTRIBUTING.md
Outdated
* avoid invariant collection types (`List`, `Dict`) in argument | ||
* use built-in generics (`list`, `dict`, `tuple`, `set`), instead | ||
of importing them from `typing`, **except** for arbitrary length tuples | ||
(`Tuple[int, ...]`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful here to link to the mypy issue, so we can easily refer back to it.
The pytype failures are strange:
@rchen152 do you know what could be causing this? |
They're strange because pytype is crashing :/
Looking. |
See python/typeshed#5055. typeshed is moving toward using types from builtins and collections.abc rather than typing (PEP 585). Mostly, this should just work with pytype, since we rewrite typing.X to builtins.x anyway, and the collections.abc types are represented as aliases of the typing ones. However, typing.Callable has its own pytd node type, so we need to special-case collections.abc.Callable in the parser. Since Tuple also has a special node type, I added a test for Tuple as well - that appears to already be working. PiperOrigin-RevId: 359096397
This is fixed in pytype-2021.02.23. (I retriggered the pytype check, and it seems happy now.) |
Awesome, thanks for the quick fix! |
Also remove conventions enforced by black and remove old note about optional default arguments (now part of PEP 484 and enforced by CI).
Unfortunately, due to python/mypy#9980 we need a special rule for
Tuple[x, ...]
.