[GRASS-dev] Moving to Black for Python formatting

Luca Delucchi lucadeluge at gmail.com
Fri Feb 26 04:01:12 PST 2021

On Fri, 26 Feb 2021 at 06:00, Vaclav Petras <wenzeslaus at gmail.com> wrote:
> Dear all,

Dear Vaclav,

> Black is now applied to all except for GUI code (that will change hopefully soon). There are few exceptions in place, most notably ctypes. The compliance is checked using Checks in each PR (aka GitHub Actions). The version used is Black 20.8b1. It will be updated as new releases come with possibly small changes to the formatting of the code.
> Use the same Black version locally, but if you don't, the worst thing which will happen is that the check will fail and you will need to fix your PR. There is a new file in the root of the repo called pyproject.toml which your local Black and perhaps your editor should pick up currently with settings only for Black. Obviously, the idea is that you just throw Black formatter at your file and don't care about formatting things manually anymore.
> A lot happened with Flake8 compiace, but that's mostly irrelevant to Black except that bulk of formatting issues are gone which are now all enabled except line length check and one issue which conflicts with Black. This is accompanied by supporting # % and not just #% in the option parser. Thanks to this and recent Flake8-related fixes by Anna, it is possible to use Flake8 quite effectively to check for problems although a lot of issues still need to be ignored which is configured separately in each major directory containing Python code.
> Several non-whitespace changes were included in the Black formatting, namely updates of remaining u-string literals to Python 3 and some trailing comma syntax which now makes Python 3.6 the minimum.
> There is also a PR #1391 which will make it easy to ignore these (and other) formatting commits when doing git blame in the command line. The GitHub web interface offers an easy way to move over a revision.

thanks a lot for the explanation

> All this applies to core repo, not the grass-addons repo. Ideas and volunteers are welcome.

Do you have any suggestions on how to proceed to grass-addons?
Did you just run blake inside a folder or did you do something more?

> Best,
> Vaclav



More information about the grass-dev mailing list