clever-father-91273
06/13/2023, 11:43 AMpants lint ::
it fails claiming isort would make changes. So I run pants fmt ::
and isort indeed does make changes. Then I run lint
again, and it wants to revert the changes it made. This issue appeared after I upgraded to Pants 2.15 from an earlier version. Am I doing something wrong?
I have seen https://www.pantsbuild.org/v2.17/docs/python-linters-and-formatters#isort-possible-issues-with-its-import-classifier-algorithm, and based on this I updated my [isort]
section in pants.toml
by adding the appropriate args, but it didn't help.
Thanks!happy-kitchen-89482
06/13/2023, 7:59 PMhappy-kitchen-89482
06/13/2023, 8:00 PMhappy-kitchen-89482
06/13/2023, 8:01 PMhappy-kitchen-89482
06/13/2023, 8:01 PMclever-father-91273
06/26/2023, 10:46 AMmy_module_A
.
The imports are as follows:
import os
import pandas as pd
from my_module_B import stuff
from my_module_A import other_stuff
I'm indifferent to treating my_module_B
as an external lib (like pandas) or internal (like my_module_A
).
Running lint makes isort fail on this file. So I call fmt. No changes made in this file. Lint still says it's wrong. Fmt still makes no chages. So I run isort without pants. It changes the imports as follows:
import os
import pandas as pd
from my_module_A import other_stuff
from my_module_B import stuff
I'm fine with this, too. I run lint -- it fails. Run fmt -- it changes to the initial imports layout. Run lint again - still fails.happy-kitchen-89482
06/26/2023, 5:04 PMhappy-kitchen-89482
06/26/2023, 5:04 PMhappy-kitchen-89482
06/26/2023, 5:05 PM__init__.py
files that affects thisbrash-glass-61350
11/23/2023, 1:38 PMpants fmt ::
does nothing, but in pants lint ::
isort complains 😕brash-glass-61350
11/23/2023, 1:46 PMhappy-kitchen-89482
11/23/2023, 4:30 PMhappy-kitchen-89482
11/23/2023, 4:30 PMhappy-kitchen-89482
11/23/2023, 4:30 PMbrash-glass-61350
11/24/2023, 11:44 AMknown_first_party = ["lib"]
to pants.toml
, but I just got an error message saying unknown field or something like that. I am supposed to put it somewhere else?happy-kitchen-89482
11/24/2023, 9:03 PMbrash-glass-61350
11/27/2023, 1:16 PMrich-london-74860
12/13/2023, 8:30 PMknown_first_party
configuration fixes the problem, but that’s not a reasonable long-term solution. That would mean that every time we add another project to the root, which we do often, then we would have to update this configuration.
Is there a way to pass this configuration through the command line? I see here that it is possible with -p/--project
in isort
, but I’m not sure how to pass that through pants
. If this is possible, then we could use a command to dynamically create this list before passing it to isort
.
Alternatively, I guess we could write a plugin to dynamically write .isort.cfg
. In that case, is it possible to alias fmt
and lint
such that another plug-in runs before fmt
and lint
?happy-kitchen-89482
12/13/2023, 11:04 PMhappy-kitchen-89482
12/13/2023, 11:04 PMhappy-kitchen-89482
12/13/2023, 11:05 PMhappy-kitchen-89482
12/13/2023, 11:09 PMrich-london-74860
12/14/2023, 3:18 AMnutritious-hair-72580
02/22/2024, 10:01 PM