Closed as not planned
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