-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
F821
on use of Literal
with strings, e.g. Literal['foo']
#128
Comments
I have no idea how you differentiate in a general way between the following: from typing import Literal
def foo(x: Literal['int']):
pass from typing import List
def foo(x: List['int']):
pass from .local_types import CustomThing
def foo(x: CustomThing['int']):
pass Obviously you can whitelist I guess you have to assume it's parameterised with types, can maybe one day allow a magic comment or magic property which tells ruff that |
Yeah it looks like PyFlakes special-cases PyFlakes actually has a lot of custom logic for caching forward-reference annotation in |
(The |
@vianmixtkz - This was fixed long long ago. How are you importing |
Gotcha, I was importing it from another module. I tried to import it directly from typing and it fixed the issue. What caused that though ? |
If you add that module to |
Since #119 was fixed via #125, I tried ruff again (build from
main
) with pydantic.I get a few remaining
F821
errors due to use of strings inLiteral
, the line numbers are also incorrect - seems to always be1
.From this code (and some other places in that file), I get:
Example code:
The text was updated successfully, but these errors were encountered: