Isort: Config in pyproject.toml doesn't override global .isort.cfg

Created on 1 May 2020  ยท  3Comments  ยท  Source: PyCQA/isort

When configuring isort via pyproject.toml the settings were merged with those in ~/.isort.cfg. However when using a project-local .isort.cfg all global settings are ignored.

For example, given a global ~/.isort.cfg:

[settings]
combine_as_imports=True

a pyproject.toml:

[tool.isort]
use_parentheses = true

a project-local .isort.cfg:

[settings]
use_parentheses = True

and a python file foo.py:

from marshmallow import Schema as ValidationSchema, fields

I've tested the following combinations with this command: isort --check-only --diff

The diff mentioned in the table below is this one splitting as imports onto a new line:

-from marshmallow import Schema as ValidationSchema, fields
+from marshmallow import Schema as ValidationSchema
+from marshmallow import fields

~/.isort.cfg | .isort.cfg | pyproject.toml | Produces Diff?
----------- | --------- | -------------- | -----
โŒ | โœ… | โŒ | โœ…
โŒ | โŒ | โœ… | โœ…
โœ… | โœ… | โŒ | โœ…
โœ… | โŒ | โœ… | โŒ

Since combine_as_imports is false by default, the unexpected output here is the fourth combination (~/.isort.cfg & pyproject.toml) which I would have expected to produce a diff since pyproject.toml doesn't have combine_as_imports = true set.

Most helpful comment

These type of issues should be fixed in the latest 5.0.0 release of isort: https://timothycrosley.github.io/isort/docs/major_releases/introducing_isort_5/

Thanks for everyone for reporting them to help me prioritize!

~Timothy

All 3 comments

Thank you for pointing this out! I was having issues getting black and isort to behave together, sure it was some unaddressed aspect of #694, but it was really just my old ~/.isort.cfg file causing compatibility issues.

This seems to be a problem with both pyproject.toml and setup.cfg. Using an .isort.cfg project file instead is a workaround for me.

I've just had this issue too.

Edit: On reflection, it wasn't this issue exactly, but it is related. I'll open a new issue.

These type of issues should be fixed in the latest 5.0.0 release of isort: https://timothycrosley.github.io/isort/docs/major_releases/introducing_isort_5/

Thanks for everyone for reporting them to help me prioritize!

~Timothy

Was this page helpful?
0 / 5 - 0 ratings