bpo-46644: Remove callable() requirement from typing._type_check#31151
bpo-46644: Remove callable() requirement from typing._type_check#31151JelleZijlstra merged 9 commits into
Conversation
We also remove all the tests that check for integer literals
|
Since there is still discussion going on in bpo this should not yet be merged. |
Sorry, something went wrong.
JelleZijlstra
left a comment
There was a problem hiding this comment.
I still think we should move forward with this change and close the alternative #31159 (cc @gvanrossum @Fidget-Spinner @serhiy-storchaka). Being permissive in the typing.py runtime helps make innovation in the type system possible.
PEP 612 and 646 were difficult to implement in typing-extensions because of overly strict checks in typing.py (e.g. https://github.com/python/typing/blob/95c9c2bab2034f0359e8457360d93a288a65e55d/typing_extensions/src/typing_extensions.py#L1860, https://github.com/python/typing/blob/95c9c2bab2034f0359e8457360d93a288a65e55d/typing_extensions/src/typing_extensions.py#L1900). To make future PEPs easier to implement, I want to generally keep runtime checks in typing.py at a minimum. This PR removes a check that has been particularly problematic.
Sorry, something went wrong.
gvanrossum
left a comment
There was a problem hiding this comment.
Yes, that’s fair. Godspeed!
Sorry, something went wrong.
Fidget-Spinner
left a comment
There was a problem hiding this comment.
LGTM. Feel free to ignore my comment below.
Sorry, something went wrong.
We remove tests that check for int literals. A check that a type isn't a tuple literal was added to cover cases like
Final[int, str]. This codepath wasn't covered forTypeGuardso I added a test for it. Note we already disallow tuple types since things like Union[typeform]->typeform, but Union[typeform, typeform] -> Union[typeform, typeform].https://bugs.python.org/issue46644