Thanks to visit codestin.com
Credit goes to github.com

Skip to content

New analyzer: module processing order may affect import resolution #7157

@JukkaL

Description

@JukkaL

These two test cases should be equivalent (with new semantic analyzer), but the second generates an error. The only difference is the order in which modules are processed within an import cycle.

[case testNewAnalyzerImportStarForwardRef1]
import a

[file a.py]
x: A

from b import * # No error

class A: pass

[file b.py]
MYPY = False
if MYPY:
    from a import x

[case testNewAnalyzerImportStarForwardRef2]
import a

[file a.py]
x: A

MYPY = False
if MYPY:
    from b import * # Unexpected error: Name 'x' already defined on line 1

class A: pass

[file b.py]
from a import x

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions