-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Closed as not planned
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Hi,
I discovered a bug when using the Final
attribute along with slots=True
in dataclasses. The bug is more described in this stackoverflow post where someone with more knowledge has explained to me why this happens and which code line causes this issue:
https://stackoverflow.com/questions/78039353/why-does-slots-not-work-with-final-dataclass-attribute
Here is a minimal example:
#!/usr/bin/env python3
from __future__ import annotations
from dataclasses import dataclass
from typing import Final, ClassVar
@dataclass(slots=True)
class Child():
VERSION: Final[str] = '1.0.0'
@classmethod
def check_version(cls, version: str) -> bool:
return version == cls.VERSION
print(Child.check_version('1.0.0'))
# Returns False
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error