question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce black formatting in the codebase

See original GitHub issue

I 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:

  1. We ignore all existing files and impose black on new files to avoid backport issues and conflicts in PRs
  2. 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:open
  • Created 10 months ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
mattipcommented, Nov 17, 2022

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.

0reactions
eli-schwartzcommented, Nov 23, 2022

I think that’s exaggerating it.

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:

def foo(....) -> ...:
    do_things()

to this:

def foo(
    ...
) -> ...:
    do_things()

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found