You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a project is under git version control it doesn't seem to use the .isort.cfg file in the user's $HOME folder anymore.
Steps to reproduce:
~ $ docker run -it --rm debian:testing /bin/bash
root@bdb47edb19d8:/# apt-get update
...
root@bdb47edb19d8:/# apt-get install git python3 python3-pip
...
root@91a7d05011e0:/# cat > .isort.cfg << EOL
> [settings]
> line_length=79
> multi_line_output=3
> include_trailing_comma=True
> force_grid_wrap=2
> combine_as_imports=True
> balanced_wrapping=True
> EOL
root@91a7d05011e0:/# mkdir test && cd test
root@91a7d05011e0:/test# cat > utils.py << EOL
> def do_a():
> pass
>
> def do_b():
> pass
> EOL
root@91a7d05011e0:/test# cat > main.py << EOL
> from utils import (
> do_a,
> do_b,
> )
> EOL
root@91a7d05011e0:/test# pip install isort
...
Successfully installed isort-5.4.2
root@91a7d05011e0:/test# isort --diff main.py # No output, imports sorted according to .isort.cfg in $HOME dir
root@91a7d05011e0:/test# git init
Initialized empty Git repository in /test/.git/
root@91a7d05011e0:/test# isort --diff main.py # Output, imports not sorted according .isort.cfg in $HOME dir anymore
--- /test/main.py:before 2020-08-26 16:50:24.192227
+++ /test/main.py:after 2020-08-26 16:51:42.572927
@@ -1,4 +1 @@
-from utils import (
- do_a,
- do_b,
-)
+from utils import do_a, do_b
root@91a7d05011e0:/test# rm -fr .git
root@91a7d05011e0:/test# isort --diff main.py # No output, .isort.cfg in $HOME dir used again after removing .git folder
root@91a7d05011e0:/test#
The behavior changed since isort 5.0.0. Earlier versions of isort used the .isort.cfg in the user's $HOME folder also when the project is under git.
I know I can use an .isort.cfg file at the project level but sometimes it's more convenient to have a 'global' config, especially on projects which don't use isort.
Is this the intended behavior now?
The text was updated successfully, but these errors were encountered:
Thanks for reaching out! The reason the behaviour changed was really that the usage of isort has evolved over the years. Originally since isort was a new tool it was used primarily from individual developers to clean up their own code. They would do this independent from any project level guidelines. This was actually the usage I initially designed isort for. However, overtime as isort got better and better at its job of sorting imports, projects started feeling comfortable requiring isort for all commits, and it started being centered more around projects and less around individual developers. This led to many issues on the isort code base where individual developer config files were conflicting with the projects imports. And projects should be able to use isort without any config set, just like users can, and rest assured that there wont be any conflicts.
That said, I still use isort even on the few code bases I interact with that don't have it included. And certainly, I want to support both use cases well. What I do for now, is set the settings path to my personal config If I'm interacting with one of those code bases:
isort --sp ~/.isort.cfg .
You can also set up an alias to make this behaviour automatic.
I'm also very open to other strategies to support both modes of operation well.
When a project is under git version control it doesn't seem to use the .isort.cfg file in the user's $HOME folder anymore.
Steps to reproduce:
The behavior changed since isort 5.0.0. Earlier versions of isort used the .isort.cfg in the user's $HOME folder also when the project is under git.
I know I can use an .isort.cfg file at the project level but sometimes it's more convenient to have a 'global' config, especially on projects which don't use isort.
Is this the intended behavior now?
The text was updated successfully, but these errors were encountered: