It's certainly not my goal to be misleading. Here's my perspective.
In Python, if you evaluate an undefined name, Python raises a
NameError. This is so consistent I'm willing to call it a "rule".
Various folks have proposed an exception to this "rule": evaluating an
undefined name in an PEP 649 delayed annotation wouldn't raise
NameError, instead evaluating to some yet-to-be-determined value
(ForwardRef, AnnotationName, etc). I don't think annotations are
special enough to "break the rules" in this way.
Certainly this has the potential to be irritating for code using
annotations at runtime, e.g. Pydantic. Instead of catching the
exception, it'd have to check for this substitute value. I'm not sure
if the idea is to substitute for the entire annotation, or for just the
value that raised NameError; if the latter, Pydantic et al would have to
iterate over every value in an annotation to look for this special value.
As a consumer of annotations at runtime, I'd definitely prefer that they
raise NameError rather than silently substitute in this alternative value.
//arry
/
On 10/21/21 8:01 PM, Guido van Rossum wrote:
On Thu, Oct 21, 2021 at 10:35 AM Larry Hastings <la...@hastings.org
<mailto:la...@hastings.org>> wrote:
.
Your proposal is one of several suggesting that type annotations
are special enough to break the rules. I don't like this idea.
But you'll be pleased to know there are a lot of folks in the
"suppress the NameError" faction, including Guido (IIUC).
Yes, I still want this part of your PEP changed. I find your
characterization of my position misleading -- there is no rule to
break here(*), just an API.
(*) The Zen of Python does not have rules.
--
--Guido van Rossum (python.org/~guido <http://python.org/~guido>)
/Pronouns: he/him //(why is my pronoun here?)/
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/T72R3LFOSW4KFHO3GCZW3F2BCTGGAWD4/
Code of Conduct: http://python.org/psf/codeofconduct/