New semantic analyzer: better error messages for cyclic cross-module definitions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
This is a follow-up for https://github.com/python/mypy/pull/6527
The new analyzer gives to verbose (and a bit confusing) error in this case:
[case testNewAnalyzerCyclicDefinitionCrossModule]
import b
[file a.py]
import b
x = b.x # E: Cannot determine type of 'x'
[file b.py]
import a
x = a.x # E: Cannot resolve attribute "x", possible cyclic definition \
# E: Module has no attribute "x"
We can probably skip the second part by injecting a dummy Var with Any type in the a module namespace.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the testNewAnalyzerCyclicDefinitionCrossModule case shown in the issue and compare its expected diagnostics with the new analyzer behavior. Read the follow-up context in pull request 6527 and trace how cyclic cross-module attributes are resolved. Done means the redundant diagnostic is removed while the useful cyclic-definition error remains covered by the test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100