basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

generic bound `TypeVar` broke with `Callable`

Open KotlinIsland opened this issue 2 years ago • 0 comments

from typing import Callable, TypeVar

R = TypeVar("R")
StrFn = TypeVar("StrFn", bound=Callable[[str], R])


def deco(fn: StrFn) -> StrFn:
    return fn


@deco
def foo(value: str):  # error, incorrect
    ...


@deco
def bar(value: str, value2: str = ""):  # error, incorrect
    ...

@deco
def baz(value: str, value2: str):  # error, correct
    ...

KotlinIsland avatar Feb 02 '23 03:02 KotlinIsland