interesting behaviour with isort: `./pants fmt :: ...
# general
a
interesting behaviour with isort:
./pants fmt :: --no-pantsd
with
Copy code
# pants.toml
[isort]
config = "build-support/pyproject.toml"
is different from
isort --settings-path build-support/pyproject.toml
h
How’s the behavior diverging? I had issues getting isort 5.x to behave properly: https://www.pantsbuild.org/docs/python-fmt-goal
a
with pants it behaves as if there was no pyproject.toml
with normal isort it behaves as expected
isort >=5.6.4
h
Ohhhh
--settings-path
is a new option! We haven’t wired that up to Pants because we had isort 4 when adding it Would you be interested in contributing a fix? I can send some instructions
a
sure
thank you 😃
i tried all the suggested things in the docs but no luck
h
Awesome, so we want to update https://github.com/pantsbuild/pants/blob/bc4a8fb3f07f6145649f02b06a1e5599aa28b36c/src/python/pants/backend/python/lint/isort/rules.py#L60-L68 to include
--settings-path
if
isort.config
is defined https://github.com/pantsbuild/pants/blob/bc4a8fb3f07f6145649f02b06a1e5599aa28b36c/src/python/pants/backend/python/lint/bandit/rules.py#L48-L58 is an example of this, but a difference is that Bandit is only ever one config file, whereas this could be multiple files for isort. Where it gets tricky is that we can’t use this option if you’re on isort 4. I think you can use
Requirement.parse(isort.version).specifier
to dynamically see if isort 4 might be resolved, e.g.
.specifier.contains("4")
. There’s a little wonkiness irc though between whether you want
.specifier.contains("4")
or need something more precise like
specifier.contains("4.0.0")
👍 1
a
thank you, i will have a look this weekend
❤️ 1
the temporary workaround is:
Copy code
[isort]
config = "build-support/pyproject.toml"
args = "--settings-path=build-support/pyproject.toml"
💯 1