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 type arguments are used for Callable within isinstance call #6101

Closed
erictraut opened this issue Oct 7, 2023 · 1 comment
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

Pyright emits an error when the second argument to an isinstance call supplies type arguments. This condition results in a runtime exception, so it should be flagged.

if isinstance(1, list[int]): # Error reported
    ...

However, pyright doesn't provide an error when type arguments are supplied for Callable.

from typing import Callable

if isinstance(1, Callable[[], str]): # No error reported
    ...
@erictraut erictraut added the bug Something isn't working label Oct 7, 2023
erictraut pushed a commit that referenced this issue Oct 7, 2023
erictraut pushed a commit that referenced this issue Oct 7, 2023
erictraut added a commit that referenced this issue Oct 7, 2023
… `isinstance` call. This addresses #6101. (#6103)

Co-authored-by: Eric Traut <erictr@microsoft.com>
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Oct 7, 2023
@erictraut
Copy link
Collaborator Author

This is addressed in pyright 1.1.331, which I just published. It will also be included in a future release of pylance.

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