Let's fix code to be PEP8 compliant?
See original GitHub issueIs your feature request related to a problem? Please describe.
I am working on a couple PRs for locust and my IDE automatically removes trailing spaces and whitespace from blank lines. This means when I want to make a change to a file in the repo it also edits many lines to “fix” them. It’s a bit annoying as I then have to go and undo all the changes. I know I could disable the feature but it has good intentions 😃
Example output from pycodestyle
:
$ pycodestyle locust/exception.py
locust/exception.py:4:1: E302 expected 2 blank lines, found 1
locust/exception.py:7:1: E302 expected 2 blank lines, found 1
locust/exception.py:10:1: E302 expected 2 blank lines, found 1
locust/exception.py:13:1: E302 expected 2 blank lines, found 1
locust/exception.py:17:1: W293 blank line contains whitespace
locust/exception.py:20:80: E501 line too long (91 > 79 characters)
locust/exception.py:25:1: E302 expected 2 blank lines, found 1
locust/exception.py:28:1: E302 expected 2 blank lines, found 1
locust/exception.py:31:1: W293 blank line contains whitespace
locust/exception.py:32:80: E501 line too long (86 > 79 characters)
locust/exception.py:32:87: W291 trailing whitespace
locust/exception.py:33:80: E501 line too long (85 > 79 characters)
locust/exception.py:36:1: E302 expected 2 blank lines, found 1
locust/exception.py:38:80: E501 line too long (81 > 79 characters)
locust/exception.py:41:1: E302 expected 2 blank lines, found 1
locust/exception.py:48:1: E302 expected 2 blank lines, found 1
locust/exception.py:55:1: E302 expected 2 blank lines, found 1
Describe the solution you’d like
Fix all current formatting so it’s PEP8 compliant and then add a Github action to enforce it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
How to Write Beautiful Python Code With PEP 8 - Real Python
Learn how to write high-quality, readable code by using the Python style guidelines laid out in PEP 8. Following these guidelines helps you...
Read more >Tool to convert Python code to be PEP8 compliant
I don't think there's any tool that converts the code to PEP8 compatible code. PEP8 included variable naming rules as well , so,...
Read more >PEP 8 – Style Guide for Python Code
However, you should use the suffix “Error” on your exception names (if the exception actually is an error). Global Variable Names. (Let's hope ......
Read more >Python PEP 8 tutorial: Get started writing readable code
Python PEP 8 helps solve that problem. The style guide was designed to help us improve the readability of Python code.
Read more >Setting Up PEP8 and Pylint on VS Code - DEV Community
flake8 is a different linter entirely. If you're still looking for PEP 8 formatting, you can install autopep8 and change your "python.formatting ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Interesting! The drawbacks from the history rewrite solution probably outweighs the benefits. I imagine any mentioned commit hash in github comments, line comments in PRs, etc. will probably get lost as well.
I didn’t know about
--ignore-revs-file
, and it should definitely be helpful - especially if Github implements support for it at some point.It is possible to migrate the code style with Black without ruining git blame by ignoring revisions with
--ignore-revs-file
flag. [source]