-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-dataclassestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
In the following:
import dataclasses
@dataclasses.dataclass(slots=True)
class Base:
def __init_subclass__(cls) -> None:
print(cls.__qualname__)
class Container:
@dataclasses.dataclass(slots=True)
class Dataclass(Base):
pass
I get:
Container.Dataclass
Dataclass
(I can handle the double-call, but the second call having incorrect __qualname__
is just really annoying 😂 )
To clarify the annoyance, the real world use case looks something like:
@dataclasses.dataclass(slots=True)
class Base:
def __init_subclass__(cls) -> None:
if "__slots__" not in cls.__dict__:
return # We're the unslotted class, wait until we're the slotted "real" one
... # Some code here relying on `__qualname__`
CPython versions tested on:
3.11
Operating systems tested on:
macOS
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-dataclassestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error