I agree with Jelle and Guido. The name isn't perfect, but I haven't seen any suggestions that seem better to me (and can't think of any myself). The function will be useful; I think it's time to move forward with this proposal.

Best, 
Alex

-------- Original message --------
From: Guido van Rossum <guido@python.org>
Date: 07/03/2022 04:33 (GMT+00:00)
To: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Cc: Anton Agestam <git@antonagestam.se>, Martin DeMello <mdemello@google.com>, None via Typing-sig <typing-sig@python.org>
Subject: [Typing-sig] Re: Proposal: typing.assert_type() and with typing.assert_error()

Even though I did have initial objections I have grown to like the current term and I see no reason to change it.

On Sun, Mar 6, 2022 at 18:33 Jelle Zijlstra <jelle.zijlstra@gmail.com> wrote:
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
--
--Guido (mobile)