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

apply different settings in different subdirectories #1849

Closed
temyurchenko opened this issue Nov 11, 2021 · 5 comments
Closed

apply different settings in different subdirectories #1849

temyurchenko opened this issue Nov 11, 2021 · 5 comments
Labels
question Further information is requested

Comments

@temyurchenko
Copy link

Hi, I have a project-wide isort configuration in pyproject.toml. However, in a certain subdirectory I'd like to have different settings. I've created a .isort.cfg file in that directory with the desired settings.

I expect that running isort . in the root directory would result in formatting files in that subdirectory according to the rules in the .isort.cfg.

I get those files formatted according to the rules in pyproject.toml.

What can I do to achieve the desired?

@anirudnits
Copy link
Collaborator

This is a recent enhancement to isort to support multiple config files across sub-directories. You can find some the flags here:

"--resolve-all-configs",
and
"--config-root",
. As an example, you could do something like this
isort directory --resolve-all-configs --config-root directory and that should do the trick.

I'll add separate documentation about this in the config files section.

Hope this helps and let me know if there are any more concerns.

~Aniruddha

@anirudnits anirudnits added the question Further information is requested label Nov 12, 2021
@anirudnits
Copy link
Collaborator

#1850

@temyurchenko
Copy link
Author

temyurchenko commented Nov 13, 2021

Thanks a lot for that feature! It seems to work pretty good in general, but it doesn't seem to account for supported_extensions. Here's a minimal subconfig .isort.cfg:

[settings]
line_length=100
known_first_party=evm
supported_extensions=["cairo"]

Files like *.cairo don't get reformatted.

@anirudnits
Copy link
Collaborator

anirudnits commented Nov 13, 2021

Thanks @murcake for pointing this out! I'll have a look and will work to remediate this in the coming releases.

One other thing, acting on your question, I added documentation regarding this feature, you can check it out here: https://github.com/PyCQA/isort/pull/1850/files, if you think that the added documentation lacks in anyway do let me know.

@temyurchenko
Copy link
Author

The documentation is good)

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

No branches or pull requests

3 participants