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

Inconsistently rewrites W504/3 (newline after/before binary operator) #456

Closed
asottile opened this issue Dec 4, 2018 · 3 comments
Closed
Assignees

Comments

@asottile
Copy link
Contributor

asottile commented Dec 4, 2018

Consider this input, which has two lines of whitespace above the function

q = 1


def x(y, z):
    if (
            y and
            z
    ):
        pass

autopep8 will not touch it (this is good, this is what I expect)

However if it has more line breaks at the top this happens:

 q = 1
-
-
 
 
 def x(y, z):
     if (
-            y and
-            z
+            y
+            and z
     ):
         pass

I don't think autopep8 should be rewriting W504 / W503 unless asked to and especially not when fixing an unrelated issue. pycodestyle and flake8 by default turns those warnings off

$ /home/asottile/.cache/pre-commit/repoadsj3zb8/py_env-python3/bin/autopep8 --version
autopep8 1.4.2 (pycodestyle: 2.4.0)
@asottile
Copy link
Contributor Author

asottile commented Dec 4, 2018

just checked, this also happens with 1.4.3

@asottile
Copy link
Contributor Author

seems an ignore setting is required to trigger this as well now that I'm debugging it

@asottile
Copy link
Contributor Author

this one is quite interesting!

$ .tox/py36/bin/autopep8 noop.py  --ignore=E501 --verbose
[file:t.py]
--->  Applying global fix for E265
--->  1 issue(s) to fix {'W504': {6}}
--->  1 issue(s) to fix {'W503': {7}}
q = 1


def x(y, z):
    if (
            y and
            z
    ):
        pass
$ .tox/py36/bin/autopep8 t.py  --ignore=E501 --verbose
[file:t.py]
--->  Applying global fix for E265
--->  2 issue(s) to fix {'E303': {5}, 'W504': {7}}
--->  1 issue(s) to fix {'W503': {7}}
--->  1 issue(s) to fix {'W504': {6}}
q = 1


def x(y, z):
    if (
            y
            and z
    ):
        pass

I suspect the "fix" here is that if the ignore does not handle the conflicting options, autopep8 should ignore the conflicting options

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

2 participants