-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-43766: Implement PEP 647 (User-Defined Type Guards) in typing.py #25282
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
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.
Thank you again! I have a bunch of editorial nits.
Co-Authored-By: Guido van Rossum <[email protected]>
Wow, you're on a roll with the typing reviews today! Thanks for taking the time to review the docs Guido! Re: the comments about runtime mishaps, here's a snippet from lower down in the docs: .. note::
Strict type narrowing is not enforced - ``TypeB`` need not be a narrower
form of ``TypeA`` (it can even be a wider form) and this may lead to
type-unsafe results. The main reason is to allow for things like
narrowing ``List[object]`` to ``List[str]`` which would fail under strict
narrowing as ``List`` is invariant. The responsibility of
writing type-safe type guards is left to the user. Do you think |
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.
Somehow GitHub did not make it possible to see just the changes since my last review. :-(
Catching up. :-) Are there any other reviews I still owe you? I frankly have lost track.
Heh, I nearly completely rewrote that in my last review.
That part I think is just fine! |
Co-Authored-By: Guido van Rossum <[email protected]>
Technically one more: #24056 . However, please hold off on that. I've recently been internally bikeshedding on whether to convert the entire PEP 612 implementation into pure Python to reduce maintenance burden and complexity in If what I plan for works, we won't need that PR anymore. And we'll be able to revert the C code to what it was before PEP 612 - a big plus in my opinion. |
Personally, I think we can merge this. IMO the implementation is 100% there. The docs look alright too (I've re-read it a bunch of times now). And we can always fix the docs in later update. |
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.
Okay, will merge.
@gvanrossum: Please replace |
Sorry Guido, this PR broke doc builds on master because it triggers false positives in |
https://bugs.python.org/issue43766