Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config in pyproject.toml doesn't override global .isort.cfg #1185

Closed
ghickman opened this issue May 1, 2020 · 3 comments
Closed

Config in pyproject.toml doesn't override global .isort.cfg #1185

ghickman opened this issue May 1, 2020 · 3 comments

Comments

@ghickman
Copy link
Contributor

ghickman commented May 1, 2020

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.

@jvstein
Copy link

jvstein commented May 6, 2020

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.

@meshy
Copy link

meshy commented Jun 24, 2020

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.

@timothycrosley
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants