-
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
How to make peace with needed nested import statements for Ruff E402? #9091
Comments
Could you share more details why
isort action comments look similar to the |
If I load Another solution would be: import matplotlib
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib import pyplot as plt # need to be after the line above, but Ruff isort doesn't let |
I've run into this |
I'll PR it and see what the ecosystem checks say. |
This PR allows `matplotlib.use` calls to intersperse imports without triggering `E402`. This is a pragmatic choice as it's common to require `matplotlib.use` calls prior to importing from within `matplotlib` itself. Closes #9091.
You guys are amazing. Father Xmas won't forget you ;-) |
I use this lines a lot in several projects.
There's no other way that I know to set the matplotlib backend. But by doing so this will trigger E402.
isort
has some ways of handling that (see here).Of course I can fill lots of
# noqa: E402
but this is so ugly.Ideally, Ruff/isort should be smart enough to know these cases.
Also, perhaps, page E402 (and all others when reasonable) should show how to silence this warning if the user knows what's doing.
The text was updated successfully, but these errors were encountered: