stubtest false positive when `__class_getitem__` is implemented in class body and corresponding body in stub is generic
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
To Reproduce
In _mypy/_1.py:
class spam:
def __class_getitem__(cls, _, /): return cls
In _mypy/_1.pyi:
class spam[T]: ...
Expected Behavior
Stubtest should not report any errors. The class is implemented to be generic since a __class_getitem__ method is provided, and type-checked to be generic from the type parameter syntax.
Actual Behavior
error: _mypy._1.spam.__class_getitem__ is not present in stub
Stub: in file /_mypy/_1.pyi
MISSING
Runtime: in file /_mypy/_1.py:2
def (_, /)
Your Environment
- Mypy version used: 1.20.0
- Command used: python -m mypy.stubtest _mypy
- Python version used: 3.14
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 _mypy/_1.py and _mypy/_1.pyi reproduction and run python -m mypy.stubtest _mypy. Trace how stubtest compares class_getitem with a generic class declared using type parameter syntax; done means the command reports no missing-member error for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100