[issue26477] typing forward references and module attributes
Martijn Pieters
report at bugs.python.org
Thu Mar 3 13:38:13 EST 2016
Martijn Pieters added the comment:
> I wonder why they forward references are evaluated *at all* at this point.
The Union type tries to reduce the set of allowed types by removing any subclasses (so Union[int, bool] becomes Union[int] only). That's all fine, but it should not at that point fail if a forward reference is not available yet.
Arguably, the except NameError there should be converted to a except Exception, since forward references are supposed to be *a valid Python expression [...] and it should evaluate without errors once the module has been fully loaded.* (from the PEP); anything goes, and thus any error goes until the module is loaded.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26477>
_______________________________________
More information about the Python-bugs-list
mailing list