You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have multiple passes by SemanticAnalyzerPass3 to resolve more forward references. #4095
As mentioned in #3952 (comment) some double-forward references (and other corner cases) are currently not resolved. For example this does not work:
x: AA=BB=List[int]
This is because third pass happens only once. In checker.py we have deferred nodes, and there are mini-passes over them until they are all done, I think we can adopt the same idea here and have repeated third passes.
This is however low priority since these edge cases are extremely rare and don't cause crashes, only false positives.
Yes, this is just a simple illustration, there are other more complex situations that will work at runtime, but not in mypy, all of them are purely "academic" however.
Activity
ilevkivskyi commentedon Oct 10, 2017
Related #731
gvanrossum commentedon Oct 10, 2017
Also that particular example won't work -- even if you protect the
x: Afrom crashing (e.g. usingx: 'A'),A = Bwill still crash.ilevkivskyi commentedon Oct 10, 2017
Yes, this is just a simple illustration, there are other more complex situations that will work at runtime, but not in mypy, all of them are purely "academic" however.
ilevkivskyi commentedon Oct 10, 2017
Even this one formally speaking can be protected by
if TYPE_CHECKING: ...ilevkivskyi commentedon Nov 7, 2019
This now works correctly with the new analyzer.