-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
dataclass with slots=True, init=False raises AttributeError #98247
Copy link
Copy link
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Python 3.10.4
dataclass with slots=True, init=False raises AttributeError on attribute access
from dataclasses import dataclass
@dataclass(slots=True, init=False)
class WorldState:
is_mission_running: bool = False
w = WorldState()
w.is_mission_running
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'WorldState' object has no attribute 'is_mission_running'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error