Skip to content

Add subtyping / assignability between callable types and classes #129

@dhruvmanila

Description

@dhruvmanila

Some other false positives appear to be because we lack handling of assignability/subtyping of a class literal or subclass-of type to a Callable type. I think the proper handling here (barring metaclass __call__ handling) would consider the class to be an intersection of its __init__ and __new__ signatures. But we could also do a temporary version that just uses the current Type::signatures() implementation as forgiving gradual callable.

Originally posted in astral-sh/ruff#16512 (comment)

This involves adding subtyping and assignability between:

  • CallableType and Type::ClassLiteral (high priority)
  • CallableType and Type::Instance (class instance with __call__ method)
  • CallableType and Type::SubclassOf
  • CallableType and Type::GenericAlias

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions especially welcometype propertiessubtyping, assignability, equivalence, and more

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions