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

--check-only return code regression in 4.2.3+ / Add --enforce-whitespace option #423

Closed
jacobsvante opened this issue Apr 14, 2016 · 10 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@jacobsvante
Copy link

In isort 4.2.3 and higher I no longer get a non-0 return code for formatting errors when I pass in --check-only.

Let's say I have a script called mylib.py, with the following contents:

import os
import six

Here's the behavior with different isort versions:

$ pip install isort==4.2.2
$ isort --diff mylib.py
...
@@ -1,2 +1,3 @@
 import os
+
 import six
$ isort --check-only mylib.py
ERROR: /Users/jacob/mylib.py Imports are incorrectly sorted.
$ echo $?
1
$ pip install isort=4.2.3
$ isort --diff mylib.py
...
@@ -1,2 +1,3 @@
 import os
+
 import six
$ isort --check-only mylib.py
$ echo $?
0
$ pip install isort=4.2.4
$ isort --diff mylib.py
...
@@ -1,2 +1,3 @@
 import os
+
 import six
$ isort --check-only mylib.py
$ echo $?
0
$ pip install isort=4.2.5
$ isort --diff mylib.py
...
@@ -1,2 +1,3 @@
 import os
+
 import six
$ isort --check-only mylib.py
$ echo $?
0

My CI tests are no longer failing because of this. Would be awesome if this could be fixed!

@timothycrosley timothycrosley added the bug Something isn't working label Apr 15, 2016
@timothycrosley
Copy link
Member

Hi @jmagnusson thanks for reporting! I'll see if I can get a hot fix release out soon that resolves this

Thanks!

~Timothy

@bootandy
Copy link
Contributor

Looks like check-only was changed to ignore whitespace (including new lines) here:
5f6d4bd

@timothycrosley
Copy link
Member

@bootandy you are correct, so this is indeed an intended change and not a regression. I'll go ahead and mark as closed.

Thanks!

~Timothy

@timothycrosley timothycrosley added question Further information is requested and removed bug Something isn't working labels Apr 16, 2016
@jacobsvante
Copy link
Author

Okay... So how does one check for correctly formatted imports now exactly? It was a very useful feature IMO.

@timothycrosley
Copy link
Member

@jmagnusson it still should work for checking most formatting issues, just not things like an lines between imports. This is a tough thing to get right, as peoples definition of what signifies a failure is different from group to group. What would think about a --check-only --enforce-white-space style option?

Thanks!

~Timothy

@jacobsvante
Copy link
Author

That would work for me!

@timothycrosley timothycrosley added the enhancement New feature or request label Apr 19, 2016
@timothycrosley timothycrosley changed the title --check-only return code regression in 4.2.3+ --check-only return code regression in 4.2.3+ / Add --enforce-whitespace option Apr 19, 2016
@timgraham
Copy link
Contributor

As I asked in #378 which is the PR for the original behavior change, what's the reasoning for it? I'd rather an --ignore-whitespace option to opt-in to the new behavior unless the new behavior is really more sensible.

@jdufresne
Copy link
Collaborator

I was recently bit by this as well.

Sometimes a contributor will unknowingly slip in whitespace changes. These used to be caught on the CI server, but that is no longer the case. The end result is that the next time someone runs isort --apply, they will see a lot of unrelated whitespace changes; often in files the developer didn't touch. These style changes could have been caught earlier by the automated tools.

@jacobsvante
Copy link
Author

jacobsvante commented Aug 17, 2016

@timothycrosley Would be awesome to have a release with the commit for --enforce-white-space? I'm missing this feature 😢

@Kolyunya
Copy link

Kolyunya commented Dec 18, 2016

@timothycrosley can we have a release with the --enforce-white-space option and enforce_white_space configuration parameter please? It's a really must-have feature.

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

No branches or pull requests

6 participants