Message 338387 - Python tracker

Message338387

Author xtreak
Recipients bux, eric.smith, gvanrossum, levkivskyi, xtreak
Date 2019-03-19.16:53:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553014401.11.0.0506977205445.issue36363@roundup.psfhosted.org>
In-reply-to
Content
class Spam:
    bar: typing.Optional[bar] = str

class Spaz:
    bar: typing.Optional[bar] = None

print(Spam.__annotations__)
print(Spaz.__annotations__)

{'bar': typing.Union[str, NoneType]}
{'bar': <class 'NoneType'>}

In Spam bar has str assigned to it and seems like in Spaz bar is assigned None and hence during annotation creation this evaluates to bar: typing.Optional[None] where None is the value of bar and in Spam.bar it's typing.Union[str, NoneType] instead.
History
Date User Action Args
2019-03-19 16:53:21xtreaksetrecipients: + xtreak, gvanrossum, eric.smith, levkivskyi, bux
2019-03-19 16:53:21xtreaksetmessageid: <1553014401.11.0.0506977205445.issue36363@roundup.psfhosted.org>
2019-03-19 16:53:21xtreaklinkissue36363 messages
2019-03-19 16:53:21xtreakcreate