Use analyzed type when resolving attributes via __getattr__
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Currently, there are several places in code where mypy uses .ret_type of __getattr__ function during semantic analysis to create a dummy Var if the attribute is missing. This can result in type being in unanalyzed state (UnboundType) in certain conditions (for example an import cycle) which then leaks to later stages where it can cause weird errors, and potentially even crashes.
This is especially important now, since __getattr__ can be used also outside stubs.
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 by locating the semantic-analysis code paths that use getattr's .ret_type to create a dummy Var when an attribute is missing. Trace how an UnboundType can pass through import cycles, and consider the issue complete when the analyzed type is used and unanalyzed types no longer leak into later stages or cause crashes.
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
- 35/100