-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Ruff doesn't warn on this:
import typing
y = typing.Union[int, str]
z = typing.Optional[str]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,
from typing import Union
new_types = (int, float)
def thing(arg: Union[new_types]):
...becomes
new_types = (int, float)
def thing(arg: new_types):
...(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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule