You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems to be as a result of #3215, although I don't really understand the reasoning there, the same change is made if a type is used in an annotation, and as it can still be accessed at runtime it could still cause errors.
(really the issue there seems to be invalid use of Union in the first place, afaik the only variables you can use there are type aliases, which that tuple is not)
This is also the case in the other issue linked, #3215, where as far as I can tell the issue happens whether the union is defined in a variable or directly in the annotation.
Anyway, I don't really mind too much about autofixes, but I think it would be nice to be able to have a warning for it regardless.
The text was updated successfully, but these errors were encountered:
I think it makes sense to warn on them at least. I'm hesitant to fix since it can introduce subtle bugs, such as that identified in #3215, whereby replacing Union[new_types] with new_types leads to a runtime error (since we can't know that new_types is a tuple there, and not a single type).
Ruff doesn't warn on this:
This seems to be as a result of #3215, although I don't really understand the reasoning there, the same change is made if a type is used in an annotation, and as it can still be accessed at runtime it could still cause errors.
For example,
becomes
(really the issue there seems to be invalid use of
Union
in the first place, afaik the only variables you can use there are type aliases, which that tuple is not)This is also the case in the other issue linked, #3215, where as far as I can tell the issue happens whether the union is defined in a variable or directly in the annotation.
Anyway, I don't really mind too much about autofixes, but I think it would be nice to be able to have a warning for it regardless.
The text was updated successfully, but these errors were encountered: