Skip to content

dataclass class literal subtyping with callables not working #760

@MatthewMckee4

Description

@MatthewMckee4

Summary

This snippet does not work

@dataclass
class DC:
    x: DC | None

v: Callable[[DC], DC] = DC

The reason is that __init__ for DC is not a FunctionLiteral.

Should we allow other types for these constructor functions too? (other than FunctionLiteral and Callable

astral-sh/ruff#19130 this may also help with allowing any type and converting it to callable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdataclassesIssues relating to dataclasses and dataclass_transform

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions