Uh oh!
There was an error while loading. Please reload this page.
bpo-46480: add typing.assert_type - #30843
Conversation
Uh oh!
There was an error while loading. Please reload this page.
JelleZijlstra
commented
Feb 2, 2022
@gvanrossum this one is also ready I believe. Feedback on this function in https://mail.python.org/archives/list/typing-sig@python.org/thread/MITFQ6Z45RRMXY3HNM66IC3XXS3TA3JN/#MITFQ6Z45RRMXY3HNM66IC3XXS3TA3JN was positive. (I also proposed assert_error() there, but dropped it because of negative feedback.) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
davidfstr
commented
Feb 2, 2022
It occurs to me that users of "assert_type()" may be surprised that it doesn't actually perform an assertion at runtime. Consider code like: I wonder if we might consider a word other than "assert", or maybe add the word "static" somewhere. Suggestions:
|
JelleZijlstra
commented
Feb 2, 2022
That's a reasonable concern, but it's probably better discussed on the typing-sig thread. I'm happy to change the PR if there's consensus for another name. I'll note though that |
davidfstr
commented
Feb 2, 2022
I'll plan to make a post tomorrow. |
JelleZijlstra
commented
Mar 10, 2022
@gvanrossum I think this should be ready to merge soon, since people on the typing-sig thread now seem on board with the |
AlexWaygood
commented
Mar 10, 2022
I'll try to take a look soon! |
AlexWaygood
left a comment
There was a problem hiding this comment.
Thanks! Looks pretty good, just a few thoughts :)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
JelleZijlstra
commented
Mar 12, 2022
Thanks for the review! |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: David Foster <david@dafoster.net>
JelleZijlstra
commented
Mar 12, 2022
Planning to merge this tomorrow unless I get more feedback. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
See python/cpython#30843. The implementation mostly follows that of cast(). It relies on `mypy.sametypes.is_same_type()`.
See python/cpython#30843. The implementation mostly follows that of cast(). It relies on `mypy.sametypes.is_same_type()`.
See python/cpython#30843. The implementation mostly follows that of cast(). It relies on `mypy.sametypes.is_same_type()`.
Another pending typing-sig proposal. This function serves as a static assertion to the type checker about the type of a value.
https://bugs.python.org/issue46480