happy-psychiatrist-90774
07/23/2024, 12:21 PMruff
?
I'm trying to get it to sort imports but it doesn't seem to work...better-van-82973
07/23/2024, 4:22 PMruff
a lot alongside Pants. What’s the issue that you’re running into?happy-psychiatrist-90774
07/23/2024, 8:52 PMisort
but when I run both fmt
and fix
on these imports, nothing happens to them
from pants.engine.goal import Goal
from typing import Type
import os
from pathlib import Path
from pants.base.build_root import BuildRoot
happy-psychiatrist-90774
07/23/2024, 8:53 PMruff.toml
is extremely bare-bones
[format]
quote-style = "single"
better-van-82973
07/23/2024, 9:05 PMpants
to the list of known-third-party modules to get the imports to sort properlyhappy-psychiatrist-90774
07/23/2024, 9:10 PM[lint.isort]
known-third-party = ["pants"]
happy-psychiatrist-90774
07/23/2024, 9:10 PMfmt
and fix
on a file with these imports (example
is a first-party package:
import numpy as np
import sys
import os
import example
better-van-82973
07/23/2024, 9:13 PMexample
into the known-first-party
ruff setting help?happy-psychiatrist-90774
07/23/2024, 9:14 PMhappy-psychiatrist-90774
07/23/2024, 9:14 PMhappy-psychiatrist-90774
07/23/2024, 9:14 PMimport numpy as np
import sys
import os
This is not orderedbetter-van-82973
07/23/2024, 9:15 PMimport os
import sys
import numpy as np
better-van-82973
07/23/2024, 9:15 PMruff
directly from the command line against the file, does it correctly resort the imports?happy-psychiatrist-90774
07/23/2024, 9:20 PMruff
thing...
1. created a new venv
2. installed ruff
3. ran ruff format --config ruff.toml path/to/file.py
nothing happened 😮better-van-82973
07/23/2024, 9:21 PMruff
or Pants? Looks like the formerhappy-psychiatrist-90774
07/23/2024, 9:23 PMimport numpy
import os
import sys
os.path
sys
numpy
ruff
doesn't do anything to it
Can you try the same with your config?better-van-82973
07/23/2024, 9:26 PM[lint.isort]
known-third-party = ["numpy"]
`test.py`:
import numpy
import os
import sys
os.path
sys
numpy
I then tried running:
ruff format --config ruff.toml test.py
and
ruff check --config ruff.toml --fix test.py
Neither command did anythingbetter-van-82973
07/23/2024, 9:26 PMbetter-van-82973
07/23/2024, 9:28 PMruff.toml
it works:
[lint]
extend-select = ["I"]
# Note - still works even though I commented out these lines
#[lint.isort]
#known-third-party = ["numpy"]
happy-psychiatrist-90774
07/23/2024, 9:32 PMhappy-psychiatrist-90774
07/23/2024, 9:33 PMpants fix
now produced
import os
import sys
import numpy
happy-psychiatrist-90774
07/23/2024, 9:34 PMbetter-van-82973
07/23/2024, 9:34 PM