https://pantsbuild.org/ logo
#general
Title
# general
f

flaky-artist-57016

08/04/2022, 2:59 PM
Hey all. I’m seeing a strange issue in the Python monorepo I’m working in. We have several formatters setup (autoflake, black, and isort) and I’ve run them over the whole repository with
./pants fmt ::
. After this,
./pants lint ::
shows the linters are satisfied with the work they’ve done. However, if I then run
./pants lint subdirectory::
some of the linters complain that they would make changes (
isort
in particular). Any idea what’s going on here?
./pants tailor
succeeds without issue so the BUILD files look to be in order. ’m seeing a strange issue in the Python monorepo I’m working in. If I run
1
b

bitter-ability-32190

08/04/2022, 3:00 PM
TL;DR
isort
as I understand it pokes around the directories to try and deduce firstparty code. If someone of those dirs aren't in the "bucket" we're using for formatting, isort doesn't recognize the import as firstparty
f

flaky-artist-57016

08/04/2022, 3:02 PM
Ahh that makes sense. Because the changes
isort
tries to make in those subdirectories effectively reverts some of the changes it makes when running over the whole repo.
b

bitter-ability-32190

08/04/2022, 3:19 PM
h

happy-kitchen-89482

08/04/2022, 3:30 PM
Yeah, this is an unfortunate "feature" of isort, I think the most robust workaround is to set the firstparty package explicitly in isort config.
👍 1
f

flaky-artist-57016

08/04/2022, 6:31 PM
Thanks! I got it sorted out after some reading and tinkering. For anybody else that runs into this, you’ll need to list your first-party imports in
known_first_party
in your isort config. Here is an example:
Copy code
known_first_party = module_one,module_two,module_three,other_module
4 Views