Argument type to an `IntEnum` should be compatible with `int`
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
The following example should fail
```python
from enum import IntEnum
class MyEnum(IntEnum):
VAL1 = 1
VAL2 = 2
VAL = MyEnum("this should not be allowed")
```
but it does not (on 1.1.405, Python 3.13). Running this code results in a runtime error, however.
Mypy does correctly catch the wrong argument type:
```
main.py:7: error: Argument 1 to "MyEnum" has incompatible type "str"; expected "int" [arg-type]
```
Perhaps this also affects other `Enum` types, but I haven't checked that.
Contributor guide
Research direction
No repository files or tests are named. Start by reproducing the Python 3.13 example and tracing how Pyright checks constructor arguments for IntEnum. Done means Pyright reports the string argument as incompatible, matching the shown mypy diagnostic, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100