Introduce black formatting in the codebase
See original GitHub issueI did not see any other issue related to this.
Black has allowed many open sourced project I worked on to gain more contributors, notably because people don’t fight over formatting, and they don’t fight with the CI to match the style imposed by a tool that doesn’t autocorrect the code (pycodestyle or flake8).
We have two ways to introduce black to this massive codebase if we wish to do so:
- We ignore all existing files and impose black on new files to avoid backport issues and conflicts in PRs
- We format the whole codebase at once and ignore the commit (for git blame) with https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html
Are the maintainers open to such a move?
Issue Analytics
- State:
- Created 10 months ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Paint it Black!. How we formatted our Python codebase…
Paint it Black! How we formatted our Python codebase using Black. On improving code reviews through homogeneous and consistent code formatting.
Read more >How to Auto-Format Your Python Code with Black
Black is a tool that allows you to identify errors and format your python code at the same time. Thus it makes you...
Read more >Implementing Python Black on a Legacy Codebase
Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black ......
Read more >psf/black: The uncompromising Python code formatter - GitHub
Blackened code looks the same regardless of the project you're reading. Formatting becomes transparent after a while and you can focus on the...
Read more >Avoiding ruining git blame - Black code formatter
A long-standing argument against moving to automated code formatters like Black is that the migration will clutter up the output of git blame...
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
Maybe this should all wait until after we drop python2.7. I think the potential for problems outweighs any perceived benefits from formatting this very complicated and old code base.
The converting of consistent single quotes to consistent double quotes is meh and less “but I wanted it so”.
The mangling of function signatures across multiple lines, and converting this:
to this:
is literally unreadable to me, and it is indeed so bad that I’m so unhappy that I’d convert it all back.
Surely there must be a python code formatter that solves formatting woes without making code unreadable in the process. yapf exists, at least. I haven’t personally tried it, so I cannot judge, unlike black which I’ve tried and judged. 😛 I haven’t tried blue either (seems to be black, slightly modified for single quotes and some configuration?) Seems interesting.
Of course, my opinions as a rare contributor may not be all that representative. But there you have it, for what it’s worth.