pyright icon indicating copy to clipboard operation
pyright copied to clipboard

False negative when function uses a default argument for a generic parameter

Open erictraut opened this issue 1 year ago • 0 comments

from collections.abc import Callable

default_cache: dict[str, int] = {}
def foo[T](x: T, y: dict[str, T] = default_cache) -> T: ...

def takes_identity[T](func: Callable[[T], T], value: T) -> None:
    func(value)

takes_identity(foo, "unsafe")  # no error

This comes from https://github.com/python/typing/discussions/1633#discussioncomment-8506818.

erictraut avatar Feb 18 '24 15:02 erictraut