'The Big One': A large, repository-wide formatting commit coming in ONE WEEK #4931
Replies: 2 comments 4 replies
-
Thank you for wrangling this! And for the clear instructions for everybody. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the work on this. Some requests:
I support Black (I learned about it from those old discussions on Beets, actually) and use it in a good number of projects. I think it's the right move but with a little more effort we can make the transition more graceful. Beets isn't that active and putting out a last call for commits should help smooth things over. Would it make sense to provide dev instructions to use Black on their commits before the hard changeover? This change should be easier if all the devs are already submitting Black-formatted PRs. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all!
The 'What'
This is a warning for a big, yet simple change that will be coming to the beets repository in one week. Developers should take note, but this won't impact users at all.
When beets was started, tools for formatting code, especially for Python 3, were still in their infancy. As they progressed, the minimum version that they supported crept higher due to changes in the language, and what features they could support. Beets, trying to keep the range of compatible Python versions as wide as possible, has only recently gone above the minimum version supported by one of the most popular Python formatting tools, black.
Black is a tool based on the famous quote from Henry Ford: 'Any colour, as along as it's black.' Black is a python formatter that has very little in the way of customisation. You set it and it does its thing. No changes, no variations, no fiddly formatting options.
The Impact
This is what we're bringing into beets. In one week, black will be applied to the entire repository, along with the tool isort, which applies just to import statements. This commit will change nearly every file in the repository, and nearly every line as well. For developers, this means that there will suddenly be merge conflicts, and a lot of them.
Unfortunately, this is unavoidable. There will never be a time when there are no pending PRs in the beets repository. It's a popular tool and the maintainers are volunteers. If we're going to do this, it might as well be now.
The Benefits
Moving forward, this will make all merges easier to manage, since everything will be formatted to a standard and there will be no idiomatic formatting. This will make it easier for us maintainers to evaluate, read through, and resolve merge commits when dealing with pull requests, and it will make the code more readable.
Once the 'big commit' is done, it will never need to be done again. Every PR will be held to the black standard and will be unable to be merged unless all of the formatting checks out. Luckily, there are automations for this!
What Developers Can Do
Firstly, check out #4654 for the details on the commit that is coming and the changes.
Secondly, install pre-commit! This handy tool adds hooks to the git commit process, which are checks that have to pass before you can actually do the commit. When the 'big one' is merged to development, it will activate, requiring that every new commit conform to the standard.
You can also use the tox command
tox -e format
to manually run the formatter on all files. Since this is what we'll be doing to make the commit, it'll give you a good look at how the repository will look once it's done. Workflows will ensure that this formatting will have to apply to any PRs so use a combination of pre-commit and tox to make sure that your code matches.TLDR
We're applying the black formatter to the entire codebase. This will make a great many merge conflicts so here's your warning for that.
If you have any questions, ask them here!
Beta Was this translation helpful? Give feedback.
All reactions