Skip to content

dataclasses.is_dataclass doesn't always work correctly with Generic types #92893

@Lyle-Alloy

Description

@Lyle-Alloy

This was introduced by BPO45663.

>>> import typing
... import dataclasses
... 
... T = typing.TypeVar("T")
... 
... @dataclasses.dataclass
... class A(typing.Generic[T]):
...     x: T
...     
>>> dataclasses.is_dataclass(A)
True
>>> dataclasses.is_dataclass(A[float])
False
>>> dataclasses.is_dataclass(A(0))
True
>>> dataclasses.is_dataclass(A[float](0))
True

That second dataclasses.is_dataclass call should be True

Bug reproduced on cpython 3.9.12 x86_64-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions