Skip to content

Parametrised Callable allowed only when used as type alias #1179

Open
@joelberkeley

Description

@joelberkeley

I've found a case where a Callable is not allowed when used directly, but is allowed if used as an alias

from typing import TypeVar, Callable

T = TypeVar('T')

MkFoo = Callable[[T], list[T]]

def foo(mkfoo: MkFoo) -> None:
    _ = mkfoo(0)

works, but replacing MkFoo by its definition

def foo(mkfoo: Callable[[T], list[T]]) -> None:
    _ = mkfoo(0)

produces

main.py:13: error: Argument 1 has incompatible type "int"; expected "T"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions