Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KotlinIsland opened this issue Jul 3, 2024 · 0 comments
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Jul 3, 2024

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): ...
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Jul 3, 2024
@KotlinIsland KotlinIsland changed the title (🐞) Callables are incorrectly joined into builtins.function (🐞) incompatible Callables are incorrectly joined into builtins.function Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant