Guido van Rossum <gu...@python.org> added the comment:

A simpler example shows it has nothing to do with annotations -- it is simply 
behavior of the typing module.

>>> import typing
>>> typing.Optional[str]
typing.Union[str, NoneType]
>>> typing.Optional[None]
<class 'NoneType'>
>>> 

I don't think there's a bug here, and I am closing this as "not a bug". The 
problem in the original code is that the annotation references a global name 
that is shadowed by a local (to the class body) name, and because of the 
initialization, the latter takes precedence.  (To see for yourself, use the dis 
module to disassemble the code for Spam and Spaz.)

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36363>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to