-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-enumtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
Bug Report
enum.member
-decorated functions become enum members and do not undergo self
binding, similar to static methods. The repro snippet can be run with python 3.11 and newer to confirm.
To Reproduce
from enum import Enum, member
from typing import reveal_type
class E(Enum):
@member
def A() -> int:
return 1
assert E.A.value() == 1
reveal_type(E.A)
reveal_type(E.A.value)
Expected Behavior
Green output.
Actual Behavior
main.py:6: error: Method must have at least one argument. Did you forget the "self" argument? [misc]
main.py:10: note: Revealed type is "enum.member[def () -> builtins.int]"
main.py:11: note: Revealed type is "def () -> builtins.int"
Your Environment
- Mypy version used: 1.15.0 and current master
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.12
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-enumtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly