bpo-43766: Implement PEP 647 (User-Defined Type Guards) in typing.py#25282
Conversation
gvanrossum
left a comment
There was a problem hiding this comment.
Thank you again! I have a bunch of editorial nits.
Co-Authored-By: Guido van Rossum <gvanrossum@users.noreply.github.com>
|
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 |
gvanrossum
left a comment
There was a problem hiding this comment.
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 <gvanrossum@users.noreply.github.com>
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. |
|
@gvanrossum: Please replace |
|
Sorry Guido, this PR broke doc builds on master because it triggers false positives in |
https://bugs.python.org/issue43766