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

creates syntax error with -aa --select=E,W #518

Closed
markblundeberg opened this issue Feb 8, 2020 · 3 comments
Closed

creates syntax error with -aa --select=E,W #518

markblundeberg opened this issue Feb 8, 2020 · 3 comments
Assignees
Labels
Milestone

Comments

@markblundeberg
Copy link


Python Code

I put if True: just for indentation purposes. This is excerpt from here:

if True:
    if True:
        assert_equal(self.nodes[0].getbalance(
        ), bal + Decimal('50.00000000') + Decimal('2.19000000'))  # block reward + tx

Command Line

$ autopep8 -aa --select=E,W --diff foo.py 

Output converts Decimal('50.00000000') + Decim... to Decimal('50.00 + 00000') Decim... (note that besides the movement of the +, one 0 is missing):

--- original/foo.py
+++ fixed/foo.py
@@ -1,4 +1,7 @@
 if True:
     if True:
-        assert_equal(self.nodes[0].getbalance(
-        ), bal + Decimal('50.00000000') + Decimal('2.19000000'))  # block reward + tx
+        assert_equal(
+            self.nodes[0].getbalance(),
+            bal +
+            Decimal('50.00 + 00000')
+            Decimal('2.19000000'))  # block reward + tx

Your Environment

  • Python version: 3.7.4
  • autopep8 version: autopep8 1.5 (pycodestyle: 2.5.0)
  • Platform: linux pyenv

Also appears in autopep8 1.4.3 (pycodestyle: 2.4.0), on Python 3.7.3 -- Ubuntu 19.04 stock.

But does not appear in autopep8 1.3.4 (pycodestyle: 2.3.1) on Python 3.6.9 (pyenv).

@markblundeberg
Copy link
Author

markblundeberg commented Feb 8, 2020

Possibly related, but separate bug: #463

If I remove the comment on end of line (and change 2.19000000 to 2.190000000000000000000000000 so the line is too long) then it introduces no error, but it does create bad indentation:

--- original/foo.py
+++ fixed/foo.py
@@ -1,4 +1,7 @@
 if True:
     if True:
-        assert_equal(self.nodes[0].getbalance(
-        ), bal + Decimal('50.00000000') + Decimal('2.190000000000000000000000000'))
+        assert_equal(
+            self.nodes[0].getbalance(),
+            bal +
+    Decimal('50.00000000') +
+            Decimal('2.190000000000000000000000000'))

@markblundeberg
Copy link
Author

markblundeberg commented Feb 8, 2020

Another more specific version (starting from a good result from applying just E rules):

if True:
    if True:
        assert_equal(
            self.nodes[0].getbalance(),
            bal +
            Decimal('50.00000000') +
            Decimal('2.19000000'))  # block reward + tx

Output from autopep8 -aa --select=W --diff foo2.py or autopep8 -aa --select=W5 --diff foo2.py or just autopep8 -aa --select=W503,W504 --diff foo2.py:

+++ fixed/foo2.py
@@ -3,5 +3,5 @@
         assert_equal(
             self.nodes[0].getbalance(),
             bal +
-            Decimal('50.00000000') +
-            Decimal('2.19000000'))  # block reward + tx
+            Decimal('50.00 + 00000')
+ Decimal('2.19000000'))  # block reward + tx

Seems it doesn't like the mutually contradictory behaviour of W503, W504 ...

@markblundeberg markblundeberg changed the title creates syntax error with --select=E,W creates syntax error with -aa --select=E,W Feb 8, 2020
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Feb 9, 2020
Summary:
There's no need to specify --select when we're picking all the options.

It turns out that autopep8 with W50x options is a bit buggy, so disable that for now.
hhatto/autopep8#518

Test Plan:
    arc lint --everything

(tried on flake8 3.5.0, 3.6.0, and 3.7.9 latest)

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5219
@hhatto hhatto self-assigned this Mar 3, 2020
@hhatto hhatto added the bug label Apr 1, 2020
@hhatto hhatto added this to the 1.5.1 milestone Apr 2, 2020
@hhatto
Copy link
Owner

hhatto commented Apr 4, 2020

When W, W5 and W50 are specified and W503 and W504 conflict, priority is given to W503.
This change is in #532 .

We will release version 1.5.1 with this change within two days.

Thanks

@hhatto hhatto closed this as completed Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants