-
Notifications
You must be signed in to change notification settings - Fork 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
Getting F821 Undefined name "xyz" for typing.Literal values when imported indirectly #1976
Comments
Yeah we don't track that the re-exported We do have something to support this use-case though. If you want to treat every member of [tool.ruff]
typing-modules = ["x"] (Relevant docs are here: https://github.com/charliermarsh/ruff#typing-modules) |
(The canonical use-case for this is projects that have some kind of compatibility shim over |
Neat, that is exactly the use case (reference). |
I'll close this as it is clearly pointed out in the documentation (😅) |
Oh nice! Good to know that there are more examples of this, and glad it solves your problem :) |
Solves my problem too, thank you! Though I use relative imports, so it seems to not be triggering on |
Ah good call -- filed as #2005! |
@henryiii - Heads up, I also checked out |
Description
Ruff complains with
F821 Undefined name "xyz"
for the values described in arguments typed astyping.Literal
. I was however only able to reproduce this whenLiteral
is imported indirectly (i.e. notfrom typing import Literal
).As an example, the following file passes all checks:
But this does not:
x.py
y.py
Output:
Reproduced without any configuration changes.
Ruff version:
The text was updated successfully, but these errors were encountered: