I'd like to get the assert_type proposal finished up. I think there's broad agreement that the idea is useful, but there are concerns that the assert_type() could be confusing, because people may assume it does a runtime assertion.I see the problem, but I don't see any better alternatives at the moment. Here are the alternatives that have been proposed in this thread:- static_assert_type: Wordy, and confusing with C++ static_assert which does something different.- prove_type: Probably the best option, but "prove" isn't a word we've previously used with the Python type system. It sounds to me like we're branching into automated theorem proving.- assume, assume_type: This sounds to me like a directive to the type checker to narrow a type.- check_type, type_check: This suggests a runtime typecheck even more strongly than assert_type() does.Also, the assert_type() name was independently invented by the pytype team and by Eric in https://github.com/python/typing/discussions/1030, suggesting that it's an obvious name for this concept.What do others think? I'm happy to change the name if there's consensus for some other name._______________________________________________El lun, 14 feb 2022 a las 14:24, Martin DeMello via Typing-sig (<typing-sig@python.org>) escribió:type_check(x, int) perhaps.martin_______________________________________________On Mon, Feb 14, 2022 at 1:34 PM Anton Agestam <git@antonagestam.se> wrote:How about `assume()` or `assume_type()` as a name?
The reasoning would be you assume the type at runtime, but verify (prove) that assumption with a static type checker.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: mdemello@google.com
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: jelle.zijlstra@gmail.com
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: guido@python.org