proud-byte-81916
09/14/2023, 6:56 PMpants fmt
moves my imports like this:
from dotenv import load_dotenv
from kittl.projects.my_project.ner import LogoNer, NerResult
but pants lint
complains about it and wants it like this:
from dotenv import load_dotenv
from kittl.projects.my_project.ner import LogoNer, NerResult
Any idea of which settings in .isort.cfg
do I have to change? It currently is:
[settings]
# This is to make isort compatible with Black. See
# <https://black.readthedocs.io/en/stable/the_black_code_style.html#how-black-wraps-lines>.
line_length=88
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
known_first_party=helloworld
default_section=THIRDPARTY
This is taken from https://github.com/pantsbuild/example-pythongreen-match-60388
09/14/2023, 7:06 PMisort
is new enough, you should be able to use a pyproject.toml
with the profile = "black"
config as seen here. right?sparse-lifeguard-95737
09/14/2023, 7:10 PMgreen-match-60388
09/14/2023, 7:11 PMruff
solve the problem?green-match-60388
09/14/2023, 7:12 PMbitter-ability-32190
09/14/2023, 7:13 PMbitter-ability-32190
09/14/2023, 7:13 PMproud-byte-81916
09/14/2023, 7:13 PMproud-byte-81916
09/14/2023, 7:14 PMbitter-ability-32190
09/14/2023, 7:14 PMbitter-ability-32190
09/14/2023, 7:14 PMkittl
)sparse-lifeguard-95737
09/14/2023, 7:15 PMSpecify all top level first party package in isort doesn’t sound like a proper scalable solutionit is annoying, but unless you’re making new top-level dirs all the time I have found it’s not so bad in practice
sparse-lifeguard-95737
09/14/2023, 7:15 PMproud-byte-81916
09/14/2023, 7:15 PMsparse-lifeguard-95737
09/14/2023, 7:16 PMsparse-lifeguard-95737
09/14/2023, 7:17 PMyour_source_root/
service1/
service2/
lib1/
lib2/
then you’d put known_first_party=service1,service2,lib1,lib2
sparse-lifeguard-95737
09/14/2023, 7:17 PMyour_source_root
being the root of the PYTHONPATH
/ the source root configured in pants.toml
)sparse-lifeguard-95737
09/14/2023, 7:18 PMknown_first_party=kittl
might be enoughproud-byte-81916
09/14/2023, 7:19 PMknown_first_party=kittl
as well as
known_first_party=kittl,projects,my_project
and the issue remains, really strangeproud-byte-81916
09/14/2023, 7:20 PMproud-byte-81916
09/14/2023, 7:20 PM[settings]
# This is to make isort compatible with Black. See
# <https://black.readthedocs.io/en/stable/the_black_code_style.html#how-black-wraps-lines>.
known_first_party=kittl,projects,ner_logo_gen
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
default_section=THIRDPARTY
curved-television-6568
09/14/2023, 7:33 PMcurved-television-6568
09/14/2023, 7:34 PMisort
in combination with pants sandboxing: https://github.com/pantsbuild/pants/issues/15069green-match-60388
09/14/2023, 7:37 PMcurved-television-6568
09/14/2023, 7:47 PM