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

type and Type are narrowed inconsistently when using isinstance #6252

Closed
erictraut opened this issue Oct 28, 2023 · 2 comments
Closed

type and Type are narrowed inconsistently when using isinstance #6252

erictraut opened this issue Oct 28, 2023 · 2 comments
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

This is based on a mypy bug report: python/mypy#16349.

Code sample in pyright playground

from typing import Type

class C:
    ...

def func1(t1: Type):
    if isinstance(t1, C):
        reveal_type(t1)

def func2(t2: type):
    if isinstance(t2, C):
        reveal_type(t2)
@erictraut erictraut added the bug Something isn't working label Oct 28, 2023
erictraut added a commit that referenced this issue Oct 28, 2023
…`Type` when applying `isinstance` type narrowing in some cases. This addresses #6252.
@erictraut
Copy link
Collaborator Author

The solution to this depends in part on the conclusion to this discussion in the Python Typing forum.

erictraut added a commit that referenced this issue Nov 2, 2023
#6253)

* Fixed bug that led to an inconsistency between the use of `type` and `Type` when applying `isinstance` type narrowing in some cases. This addresses #6252.

* Fixed a bug that led to a false positive when using an unpacked iterable as an argument in a call expression _after_ a keyword argument. This addresses #6247.
erictraut added a commit that referenced this issue Nov 26, 2023
…`. These should be treated the same under all circumstances. This addresses #6252.
erictraut added a commit that referenced this issue Nov 26, 2023
…`. These should be treated the same under all circumstances. This addresses #6252.
erictraut added a commit that referenced this issue Nov 26, 2023
…`. These should be treated the same under all circumstances. This addresses #6252. (#6551)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Nov 26, 2023
@erictraut
Copy link
Collaborator Author

This is addressed in pyright 1.1.338, 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