Skip to content

[red-knot] Subclasses of Any should be assignable to Callable #17701

@sharkdp

Description

@sharkdp

Subclasses of Any should be assignable to Callable. This should not be an error:

from typing import Callable, Any


class MyMock(Any):
    pass

def f(c: Callable):
    c()

f(MyMock())  # Argument to this function is incorrect: Expected `(...) -> Unknown`, found `MyMock`

(https://types.ruff.rs/e0ded89d-526c-430e-a9c5-d02b8945f81d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcometyMulti-file analysis & type inference

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions