Summary
Using ruff 0.12.10.
Start with the following code in moo.py:
def moo():
from very.long.nonsense.indeed.need.line.to.be.full.to.cause.breakage import foo
return foo()
Running ruff with (at least) these three rules enabled, currently PLC0415 triggers:
$ uvx ruff==0.12.10 check --select PLC0415,I001,RUF100 moo.py
moo.py:2:5: PLC0415 `import` should be at the top-level of a file
Because there are good reasons that the import is local, we disable (in practice, this disable is done in an editor via the ruff language server's suggested code action):
def moo():
from very.long.nonsense.indeed.need.line.to.be.full.to.cause.breakage import foo # noqa: PLC0415
return foo()
but now the line being too long causes I001 to trigger:
$ uvx ruff==0.12.10 check --select PLC0415,I001,RUF100 moo.py
moo.py:2:5: I001 [*] Import block is un-sorted or un-formatted
but if we trigger the autofix with RUF100 enabled, then what the user sees is that the noqa they added disappears, and we get back to:
def moo():
from very.long.nonsense.indeed.need.line.to.be.full.to.cause.breakage import foo
return foo()
Fixing without RUF100, we can see that we get this intermediate state:
def moo():
from very.long.nonsense.indeed.need.line.to.be.full.to.cause.breakage import (
foo, # noqa: PLC0415
)
return foo()
... but the # noqa: PLC0415 is now the line below where it needs to be, so RUF100's autofix will remove it.
Version
0.12.10
Summary
Using ruff 0.12.10.
Start with the following code in
moo.py:Running ruff with (at least) these three rules enabled, currently PLC0415 triggers:
Because there are good reasons that the import is local, we disable (in practice, this disable is done in an editor via the ruff language server's suggested code action):
but now the line being too long causes
I001to trigger:but if we trigger the autofix with RUF100 enabled, then what the user sees is that the noqa they added disappears, and we get back to:
Fixing without RUF100, we can see that we get this intermediate state:
... but the
# noqa: PLC0415is now the line below where it needs to be, so RUF100's autofix will remove it.Version
0.12.10