Fine grained mode should respect __getattr__

Open
#4,936 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
compilers

Research direction

Start with the fine-grained test case testGetAttrFine and its a.py and a.py.2 variants, then trace how getattr dependencies are recorded for classes, modules, and subclasses. Done means the shown test reports the incompatible str-to-int assignment and wildcard and normal dependencies chain correctly.

Written by the indexing model from the issue text.

Description

bug priority-1-normal topic-fine-grained-incremental

Currently this fine grained test fails:

[case testGetAttrFine]
from a import A
x: A
y: int = x.x
[file a.py]
class A:
    def __getattr__(self, attr: str) -> int:
        pass
[file a.py.2]
class A:
    def __getattr__(self, attr: str) -> str:
        pass
[out]
==
main:3: error: Incompatible types in assignment (expression has type "str", variable has type "int")

We need to trigger wildcard trigger on class or module if its __getattr__ is triggered. Also we need to be sure that this (chaining wildcard and normal deps <Base.__getattr__> -> <Base[wildcard]> and <Base.x> -> <Sub.x> etc.) works correctly on subclasses.

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.