-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Let's fix code to be PEP8 compliant? #1489
Comments
I want to go even further and use Black for autoformatting (and adding it to the build as well). I think I even added it as a ticket a long time ago, not sure where it is though. |
Do you know if your editor support |
But the problem is the locust code, not my editor. My editor is cleaning it up, and I know I can disable this feature, but it should be clean already 🙂 |
But what's the real drawback from having trailing whitespaces? When is it actually a problem (apart from when your editor is cleaning it up)? A real drawback from removing whitespace from blank lines is when you try to copy and paste a function into an interactive shell. Definitely not a huge one, but it happens and it's something I run into from time to time. The point with a |
My beef is not particular with trailing whitespace, it's just one example of a cosmetically messy code, of which there is a lot in here. There is already well defined formatting guidelines and tools to fix/enforce it because it makes working on the code base a more enjoyable experience for everyone. If you really want trailing whitespace, then no worries, just make it consistent, add it to every line and add configuration to Black (or whatever tool) to check it and keep it consistent 🙂 |
If I could go back in time and turn on some very basic formatting checks back when this project started, I would :). I just don't think it's a huge problem that there is some formatting inconsistency, and I don't think it's worth obfuscating the 10 year git history in order to achieve formatting consistency. |
It is possible to migrate the code style with Black without ruining git blame by ignoring revisions with |
It's possible to run: This will replay the full git history and apply black formatting everywhere (except when there are python syntax errors). The above should take something like an hour to run. It can probably be made faster by filtering out just changed/added files though. The big drawback here is history is rewritten which would force any collaborators to re-clone or hard reset their local repos. Also rewriting history like this is pretty scary 😬 |
Wow. That's really cool/crazy :) But I'm sure there will be some commits with broken code that Black cant format which will make it blow up, so it is probably not an option even if we were crazy :) |
@cyberw I did a test run and there's very few commits that has broken python files. When that happen those files are simply not formatted during that commit but when a later commit makes them valid python again they are formatted. So the "only" thing that might be too painful is the history rewrite for collaborators, existing PR's etc 😅 The run took 1 hour and 22 minutes |
Cool stuff! But the blame/line history for any file that was ever broken would be pretty messed up, and that might actually make it worse than @rafaelrds suggestion. Not to mention the poor sods that are trying to maintain a fork (not sure how many of those there are) |
Yeah I'm not sure how that would look 🤔
Heh yes good point. |
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 |
Is 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
:Describe the solution you'd like
Fix all current formatting so it's PEP8 compliant and then add a Github action to enforce it.
The text was updated successfully, but these errors were encountered: