lively-dusk-46231
10/22/2022, 1:55 PM./pants fmt ::
And it successfully ran black
and isort
(and I saw it doing it on multiple cores) which was pretty neat.
I then re-ran the same command and it ran super fast (10sec).
I guessed that pants realized I had not modified these files, and so used some caching to
Now, I realized that in one of my libs/
- the isort config for known_first_party
was not correct. So, I fixed that in my pyproject.toml
And reran: ./pants fmt ::
ISSUE: It says nothing needs to be changed.
When I format it using: venv/bin/isort libs/mylib/
it uses the correct configs.
When I again run: ./pants fmt ::
- it reformats it back using the older configslively-dusk-46231
10/22/2022, 1:56 PMlively-dusk-46231
10/22/2022, 2:05 PMisort
with a custom --config
)lively-dusk-46231
10/22/2022, 2:10 PM[isort].config
Which one do I add ? I have 8 different pyproject.toml files each of them have a different known_first_party
I normally use it as:
libs/abc
will consider only abc
as first party.
libs/xyz
should be considered a 3rd party importhappy-kitchen-89482
10/22/2022, 4:10 PMhappy-kitchen-89482
10/22/2022, 4:11 PM./pants fmt libs/mylib/::
vs ./pants fmt ::
?happy-kitchen-89482
10/22/2022, 4:11 PM./pants fmt libs/mylib/::
is it picking up the right config?lively-dusk-46231
10/22/2022, 4:55 PMlively-dusk-46231
10/22/2022, 5:02 PMisort libs/abc/abc.py libs/xyz/xyz.py
According to isort docs :
[The config file taken is] ... relative to the first path passed in if multiple paths are passed inSo, if files from multiple libs are passed into isort - it will cause issues. i.e. Sorting depends on the ordering of the files sent to isort. Which is scary This seems to be related but not same as issue#15069 And maybe the BatchID concept described in issue#14941 would solve this?
bitter-ability-32190
10/22/2022, 5:07 PMisort
continues to surprise me with it's quirks.bitter-ability-32190
10/22/2022, 5:08 PMbitter-ability-32190
10/22/2022, 5:11 PMisort
for maximum correctness and since we know (or at least think we know) what`isort` is gonna do.bitter-ability-32190
10/22/2022, 5:12 PMisort
would disagree on config.
This is how we run `scalafmt`: https://github.com/pantsbuild/pants/blob/97c4ede10978fe20750ddc2642149d8b8a841126/src/python/pants/backend/scala/lint/scalafmt/rules.py#L125lively-dusk-46231
10/22/2022, 5:12 PMbitter-ability-32190
10/22/2022, 5:13 PMlively-dusk-46231
10/22/2022, 5:15 PMhappy-kitchen-89482
10/23/2022, 1:15 PMbitter-ability-32190
10/23/2022, 1:19 PMbitter-ability-32190
10/23/2022, 1:20 PMhappy-kitchen-89482
10/23/2022, 4:55 PMhundreds-father-404
10/24/2022, 3:12 PMhundreds-father-404
10/24/2022, 3:12 PMlively-dusk-46231
10/24/2022, 3:17 PMhappy-kitchen-89482
10/24/2022, 3:38 PMhappy-kitchen-89482
10/24/2022, 3:39 PMhappy-kitchen-89482
10/24/2022, 3:39 PMlively-dusk-46231
10/24/2022, 3:47 PMlib1
and lib2
If I interchange the order of the folders I pass into isort - it keeps using different known_first_party
from the first folder I mention in the command
Example: Flipping the folders goes into an endless loop of fixing:
$ venv/bin/isort lib2 lib1 <----
Fixing lib2/lib2/__init__.py
Fixing lib1/lib1/__init__.py
$ venv/bin/isort lib2 lib1 <----- SAME: nothing to fix
$ venv/bin/isort lib1 lib2 <----- FLIP: Fixing again
Fixing lib1/lib1/__init__.py
Fixing lib2/lib2/__init__.py
lively-dusk-46231
10/24/2022, 3:48 PMisort 5.10.1
happy-kitchen-89482
10/24/2022, 3:49 PMhappy-kitchen-89482
10/24/2022, 3:49 PMlively-dusk-46231
10/24/2022, 3:49 PMlively-dusk-46231
10/24/2022, 3:50 PMThe config file search is done relative... to the first path passed in if multiple paths are passed in
lively-dusk-46231
10/24/2022, 3:52 PM$ venv/bin/isort lib1 lib2 --show-config | grep '"known_first_party"'
"known_first_party": ["lib1"]
$ venv/bin/isort lib2 lib1 --show-config | grep '"known_first_party"'
"known_first_party": ["lib2"]
hundreds-father-404
10/24/2022, 4:17 PM[isort].version
and [isort].lockfile
, then running ./pants generate-lockfiles --resolve=isort
lively-dusk-46231
10/25/2022, 4:27 AMisort=4
in my project because it looks like there were breaking changes in the configs and so on and I was not too keen figuring out the correct configs for isort4
But I created a smaller example with multiple configs in isort4
and agree that isort4 does not seem to have this issuehappy-kitchen-89482
10/25/2022, 3:38 PMhappy-kitchen-89482
10/25/2022, 3:39 PMhappy-kitchen-89482
10/25/2022, 3:39 PMlively-dusk-46231
10/25/2022, 4:00 PM--resolve-all-configs
which follows the older behavior of getting a config file for every file provided as inputhappy-kitchen-89482
10/26/2022, 3:37 PMhundreds-father-404
10/26/2022, 3:58 PM