Skip to content

New semantic analyzer: cannot resolve assignment to imported value from outer scope #6949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JukkaL opened this issue Jun 7, 2019 · 0 comments · Fixed by #6983
Closed

New semantic analyzer: cannot resolve assignment to imported value from outer scope #6949

JukkaL opened this issue Jun 7, 2019 · 0 comments · Fixed by #6983
Assignees
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high semantic-analyzer Problems that happen during semantic analysis

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 7, 2019

This test case fails with Cannot resolve name "A" (possible cyclic definition):

[case testNewAnalyzerTrickyX]
import b
[file a.py]
import b
class A(B): ...
class B: ...

[file b.py]
from a import A

class C:
    A = A
@JukkaL JukkaL added bug mypy got something wrong priority-0-high false-positive mypy gave an error on correct code semantic-analyzer Problems that happen during semantic analysis labels Jun 7, 2019
@JukkaL JukkaL self-assigned this Jun 11, 2019
JukkaL added a commit that referenced this issue Jun 13, 2019
Line numbers are used sometimes to decide when a name should be looked
up from an outer scope, so they should be set for placeholders.

This actually breaks some forward references to assignment-based named
tuples. The reason is that we don't set `becomes_typeinfo=True` for
the placeholders. I'm going to open a separate issue about this, as
it's an existing issue and this change only exposes it.

Fixes #6949.
JukkaL added a commit that referenced this issue Jun 13, 2019
Line numbers are used sometimes to decide when a name should be looked
up from an outer scope, so they should be set for placeholders.

This actually breaks some forward references to assignment-based named
tuples. The reason is that we don't set `becomes_typeinfo=True` for
the placeholders. I'm going to open a separate issue about this, as
it's an existing issue and this change only exposes it.

Fixes #6949.
PattenR pushed a commit to PattenR/mypy that referenced this issue Jun 23, 2019
Line numbers are used sometimes to decide when a name should be looked
up from an outer scope, so they should be set for placeholders.

This actually breaks some forward references to assignment-based named
tuples. The reason is that we don't set `becomes_typeinfo=True` for
the placeholders. I'm going to open a separate issue about this, as
it's an existing issue and this change only exposes it.

Fixes python#6949.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high semantic-analyzer Problems that happen during semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant