Various class based NamedTuple and TypedDict errors not caught
Open
Nobody has claimed this yet.
bug
priority-1-normal
topic-named-tuple
topic-typed-dict
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
This example has a bunch of errors that the semantic analyzer should probably report (and one what seems like a false positive):
from typing import NamedTuple, TypeVar, Generic
from typing_extensions import Protocol
from mypy_extensions import TypedDict
@xyz # No error
class N1(NamedTuple):
x: int
@xyz # No error
class T1(TypedDict):
x: int
class N2(NamedTuple, Protocol): # No error
x: int
class T2(TypedDict, Protocol): # No error
x: int
class M(type):
def f(cls) -> None: pass
class N3(NamedTuple, metaclass=M): # No error
x: int
N3.f() # Error
class T3(TypedDict, metaclass=M): # No error
x: int
T = TypeVar('T')
class N4(NamedTuple, Generic[T]): # No error
x: int
class T4(TypedDict, Generic[T]): # No error
x: int
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 reproducing the Python example and tracing the semantic analyzer handling of class-based NamedTuple and TypedDict definitions. Compare diagnostics for decorators, Protocol and metaclass bases, and Generic combinations with the expectations in the issue, including the reported false positive. Done means the missing errors are reported and the false positive is addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100