Skip to content

is_dataclass doesn't promise DataclassInstance #4626

@NeilGirdhar

Description

@NeilGirdhar
from dataclasses import is_dataclass

def f(X: type) -> None:
    if is_dataclass(X):
        reveal_type(X)  # information: Type of "X" is "type"

Should this be the typeshed type type[DataclassInstance]? As far as I can tell, this is

class DataclassInstance(Protocol):
    __dataclass_fields__: ClassVar[dict[str, dataclasses.Field[Any]]]

Related typing-sig post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions