pyright
pyright copied to clipboard
False negative when function uses a default argument for a generic parameter
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.