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 positive error when type(None) or NoneType is used as second argument to issubclass #6186

Closed
erictraut opened this issue Oct 17, 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

erictraut commented Oct 17, 2023

Pyright shouldn't generate an error when type(None) or NoneType is used in the second argument to issubclass.

issubclass(int, type(None))

Furthermore, this should work for type narrowing, but it doesn't currently.

def func(x: type[None] | type[int]):
    if issubclass(x, type(None)):
        reveal_type(x, expected_text="type[None]")
    else:
        reveal_type(x, expected_text="type[int]")

This is related to a bug filed in the mypy issue tracker: python/mypy#16279

@erictraut erictraut added the bug Something isn't working label Oct 17, 2023
erictraut added a commit that referenced this issue Oct 17, 2023
…e)` or `NoneType` as the second argument to `issubclass`. This addresses part of #6186.
erictraut added a commit that referenced this issue Oct 17, 2023
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Oct 17, 2023
@erictraut
Copy link
Collaborator Author

This is included in pyright 1.1.332, 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