Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:
Operating system: Linux
Python version: 3.6.3
Black version: 18.4a0
Does also happen on master: yes
I've run black on a codebase that is already flake8 compatible, and it ends up reformatting things in such a way that it fails a whole bunch of flake8 checks. For example:
➜ balrog git:(black2) ✗ flake8 auslib scripts uwsgi *.py client
➜ balrog git:(black2) ✗ black -l 120 --fast auslib scripts uwsgi *.py agent client
➜ balrog git:(black2) ✗ flake8 auslib scripts uwsgi *.py client
auslib/db.py:21:121: E501 line too long (162 > 120 characters)
from auslib.util.rulematching import matchChannel, matchVersion, matchBuildID, matchMemory, matchSimpleExpression, matchCsv, matchLocale, matchBoolean, matchRegex
^
auslib/db.py:1779:17: W503 line break before binary operator
& ((self.buildTarget == updateQuery["buildTarget"]) | (self.buildTarget == null()))
^
auslib/db.py:1780:17: W503 line break before binary operator
& ((self.headerArchitecture == updateQuery["headerArchitecture"]) | (self.headerArchitecture == null()))
^
auslib/db.py:2061:21: W503 line break before binary operator
| (self.db.releases.name == self.db.rules.fallbackMapping)
^
auslib/log.py:9:121: E501 line too long (134 > 120 characters)
log_format = "%(asctime)s - %(levelname)s - PID: %(process)s - Request: %(requestid)s - %(name)s.%(funcName)s#%(lineno)s: %(message)s"
One of the diffs that seems to be causing some of the issues is:
- ((self.product == updateQuery['product']) | (self.product == null())) &
- ((self.buildTarget == updateQuery['buildTarget']) | (self.buildTarget == null())) &
- ((self.headerArchitecture == updateQuery['headerArchitecture']) | (self.headerArchitecture == null()))
+ ((self.product == updateQuery["product"]) | (self.product == null()))
+ & ((self.buildTarget == updateQuery["buildTarget"]) | (self.buildTarget == null()))
+ & ((self.headerArchitecture == updateQuery["headerArchitecture"]) | (self.headerArchitecture == null()))
(And many more - it looks like around ~150 total flake8 failures).
This can be reproduced locally by cloning https://github.com/mozilla/balrog, changing tox.ini's max-line-length to 120 (I'm planning to change the line length at the same time as reformatting with Black), and running flake8 before & after running black.
I think this is because since #21 a linebreak is introduced before a binary operator to conform to PEP8. I would ignore W503 :)
I'll defer to someone else for E501
For "line too long", just add organizing parentheses to your assignment and it will do the correct thing. Next version is going to do that automatically.
Yeah, disable W503, it's wrong.
Sounds like this is mostly me misunderstanding the expected state. Thanks for the replies.
Most helpful comment
For "line too long", just add organizing parentheses to your assignment and it will do the correct thing. Next version is going to do that automatically.
Yeah, disable W503, it's wrong.