Skip to content

(🐞) incompatible Callables are incorrectly joined into builtins.function #17478

@KotlinIsland

Description

@KotlinIsland
from typing import Callable, _T as T
from types import FunctionType

class C:
    def __init__(self, i: int=1): ...

def join(t1: T, t2: T) -> T: ...

c1: Callable[[], object] = C
c2: Callable[[int], object] = C
result = join(c1, c2)
reveal_type(result)  # Revealed type is "builtins.function"
print(isinstance(result, FunctionType)  # False

this is not an instance of builtins.function, it is a type[C]. it should be joined into a union, or something else, either object or Callable[..., object] or something

the same defect is observed with a non-function callable instance:

class C:
    def __call__(self, i: int = 1): ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions