-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
bpo-46644: Remove callable() requirement from typing._type_check #31151
bpo-46644: Remove callable() requirement from typing._type_check #31151
Conversation
We also remove all the tests that check for integer literals
Misc/NEWS.d/next/Library/2022-02-05-22-14-44.bpo-46644.P--1Cz.rst
Outdated
Show resolved
Hide resolved
Since there is still discussion going on in bpo this should not yet be merged. |
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.
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.
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.
Yes, that’s fair. Godspeed!
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.
LGTM. Feel free to ignore my comment below.
@@ -0,0 +1 @@ | |||
No longer require valid typeforms to be callable. This allows :data:`typing.Annotated` to wrap :data:`typing.ParamSpecArgs` and :data:`dataclasses.InitVar`. Patch by Gregory Beauregard. |
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.
Each line should be under 80 chars. However since this is usually merged into the next release's changelog anyways I'm not sure if it matters.
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.
Yes, I think blurb takes care of that when it generates the full changelog.
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 forTypeGuard
so 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