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

Line-length not properly enforced, leading to spurious check failures #299

Closed
jgaren opened this issue Aug 10, 2015 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@jgaren
Copy link

jgaren commented Aug 10, 2015

Using version 3.9.6 with line_length=79, I note the following behavior for this sample input file, test.py:

from .. import views
from ..views import (
    _a,
    _xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx as xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx)


def test():
    pass
> $ isort -c test.py
> $ echo $?
0

However, the check should fail because the as import line contains 80 characters. If I fix the line length, for example by wrapping before the as, isort claims the line violates the configured policy, and suggests an alternative which in fact violates the line length limitation:

+++ /Users/jgaren/Documents/dev/styleseat/test.py:after 2015-08-10 12:23:19.281534
@@ -1,5 +1,4 @@
 from .. import views
 from ..views import (
     _a,
-    _xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx
-    as xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx)
+    _xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx as xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx)


 def test():

If I then just give up, and try to have isort skip checking the line, I encounter yet another bug.

Input:

from .. import views
from ..views import (  # isort:skip
    _a,
    _xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx as xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx)


def test():
    pass

Output of --diff:

 from .. import views
+
 from ..views import (  # isort:skip
     _a,
     _xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx as xxxxxx_xxxxxxx_xxxxxxxx_xxx_xxxxxxx)

The suggested addition of a newline would not be correct, as it results in an extra import grouping.

@timothycrosley timothycrosley added the bug Something isn't working label Sep 1, 2015
@timothycrosley
Copy link
Member

@jgaren,

Thanks for reporting this issue! I agree the behavior here is not ideal, and I'll be thinking about how to resolve it before the next release.

Thanks!

~Timothy

@timothycrosley
Copy link
Member

This is now fixed in develop and will make it into the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants