This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients bux, eric.smith, gvanrossum, levkivskyi, xtreak
Date 2019-03-19.17:15:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553015725.71.0.67252333007.issue36363@roundup.psfhosted.org>
In-reply-to
Content
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.)
History
Date User Action Args
2019-03-19 17:15:25gvanrossumsetrecipients: + gvanrossum, eric.smith, levkivskyi, xtreak, bux
2019-03-19 17:15:25gvanrossumsetmessageid: <1553015725.71.0.67252333007.issue36363@roundup.psfhosted.org>
2019-03-19 17:15:25gvanrossumlinkissue36363 messages
2019-03-19 17:15:25gvanrossumcreate