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

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

Closed
erictraut opened this issue Feb 18, 2024 · 1 comment
Closed
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@erictraut
Copy link
Collaborator

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 python/typing#1633 (reply in thread).

@erictraut erictraut added the bug Something isn't working label Feb 18, 2024
erictraut added a commit that referenced this issue May 20, 2024
…has a parameter with a generic type and a default argument value. This could lead to a typing hole when considering subtyping rules for callables. This addresses #7288.
erictraut added a commit that referenced this issue May 20, 2024
…has a parameter with a generic type and a default argument value. This could lead to a typing hole when considering subtyping rules for callables. This addresses #7288. (#7954)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label May 20, 2024
@erictraut
Copy link
Collaborator Author

This is addressed in pyright 1.1.364.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant