[issue26477] typing forward references and module attributes

2016-09-27 Thread Guido van Rossum
Guido van Rossum added the comment: Fixed by 09cc43df4509. -- nosy: +gvanrossum resolution: -> fixed status: open -> closed ___ Python tracker ___

[issue26477] typing forward references and module attributes

2016-06-30 Thread Ivan Levkivskyi
Changes by Ivan Levkivskyi : -- nosy: +levkivskyi ___ Python tracker ___ ___

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
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

[issue26477] typing forward references and module attributes

2016-03-03 Thread Antti Haapala
Antti Haapala added the comment: Indeed, the assumption is be that if a string is used, it is used there because the actual thing cannot be referenced by name at that point. Then trying to evaluate it at all would be an optimization in only those cases where it is used incorrectly /

[issue26477] typing forward references and module attributes

2016-03-03 Thread Alex Grönholm
Alex Grönholm added the comment: I wonder why they forward references are evaluated *at all* at this point. Seems senseless to me. This should be the job of the static type checker or the get_type_hints() function. -- nosy: +alex.gronholm ___

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
Martijn Pieters added the comment: A temporary work-around is to use a function to raise a NameError exception when the module attribute doesn't exist yet: def _forward_A_reference(): try: return a.A except AttributeError: # not yet.. raise NameError('A') class

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
Martijn Pieters added the comment: Sorry, that should have read "the forward references section of PEP 484". The section uses this example: # File models/a.py from models import b class A(Model): def foo(self, b: 'b.B'): ... # File models/b.py from models import a class B(Model): def

[issue26477] typing forward references and module attributes

2016-03-03 Thread Martijn Pieters
New submission from Martijn Pieters: Forward references to a module can fail, if the module doesn't yet have the required object. The "forward references" section names circular dependencies as one use for forward references, but the following example fails: $ cat test/__init__.py from .a