False positive when extending both Enum and another class
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
False positive when extending both Enum and another class:
```python
from enum import Enum
from typing import NamedTuple
class C(NamedTuple):
n: int
class E(C, Enum):
c1 = C(1) # <- Pyright error on the C constructor call
# Error message:
# Argument of type "C" cannot be assigned to parameter "n" of type "int" in function "__new__"
# "C" is not assignable to "int"
# At runtime, everything seems to work fine:
print(E.c1.n) # -> 1
print(E.c1.name) # -> 'c1'
```
The error remains if instead of being a ```NamedTuple```, C has a simple ```__init__``` method assigning ```self.n```
Tested on Python v3.14 with Pylance v2025.9.1
Contributor guide
Research direction
Run the provided example with Python 3.14 and reproduce the diagnostic for the constructor call in the multiple-inheritance Enum case. Read the handling of Enum and inherited constructors in the type checker, then add a regression test showing that the valid C(1) call produces no false positive while invalid arguments remain diagnosed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100