[issue26477] typing forward references and module attributes

Martijn Pieters report at bugs.python.org
Thu Mar 3 13:11:39 EST 2016


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 bar(self, a: 'a.A'): ...

# File main.py
from models.a import A
from models.b import B

which doesn't fail because the forward references are not being tested until after all imports have completed; creating a Union however triggers a subclass test between the different types in the union.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26477>
_______________________________________


More information about the Python-bugs-list mailing list