-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 for PYI016 Duplicate union member #15815
Comments
This is because Ruff can't be sure here that from typing import TypeAlias
Q: TypeAlias = int | int Same if you use a type Q = int | int |
I don't think it matters how it is used. AFAICT, there is literally no difference between assert int is int | int
assert int == int | int
##############################
Q = int | int
assert Q is int
q = int
assert q is q | q
assert Q is q
##############################
from typing import TypeAlias
P: TypeAlias = int | int
assert P is int
assert P is Q
assert P is q Is there any situation in which Can't speak for others, but I have definitely done this before, and it was definitely a mistake. |
From a human's perspective, it's obvious that This would be easier for Ruff if it had better type inference. But even for type checkers, differentiating type aliases from other assignments isn't easy. If it were easy, there wouldn't be any need for |
Description
Not flagged, should raise PYI016
ruff 0.9.3
The text was updated successfully, but these errors were encountered: