<div dir="ltr"><div>Dear all,</div><div><br></div><div>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.</div><div><br></div><div>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.<br></div><div><br></div><div></div><div>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.<br></div><div><br></div><div>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.</div><div><br></div><div>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.<br></div><div><br></div><div>All this applies to core repo, not the grass-addons repo. Ideas and volunteers are welcome.<br></div><div><br></div><div>Best,<br></div><div>Vaclav<br></div><div><br></div><div></div><div><a href="https://github.com/OSGeo/grass/pull/1391">https://github.com/OSGeo/grass/pull/1391</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 17, 2021 at 4:03 PM Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear all,</div><div><br></div><div>At this moment, we don't use an automatic formatter for Python code and we have only limited enforcement of basic formatting rules. This is changing as we are moving towards PEP8 formatting compliance and automatic Flake8 checks.<br></div><div><br></div><div>We need an automatic formatter and enforcement in the CI. There seems to be a clear candidate for that and that is Black (The uncompromising code formatter) which was already suggested in 2019:</div><div><br></div><div><a href="https://lists.osgeo.org/pipermail/grass-dev/2019-May/092654.html" target="_blank">https://lists.osgeo.org/pipermail/grass-dev/2019-May/092654.html</a></div><div><br></div><div>See details about how that applies to GRASS here:<br></div><div><br></div><div><a href="https://github.com/OSGeo/grass/issues/543" target="_blank">https://github.com/OSGeo/grass/issues/543</a></div><div><br></div><div>Here is a first PR (ready to be merged) which makes changes to content of scripts and adds a automatic check:<br></div><div><br></div><div><a href="https://github.com/OSGeo/grass/pull/1347" target="_blank">https://github.com/OSGeo/grass/pull/1347</a></div><div><br></div><div>Best,<br></div><div>Vaclav<br></div></div>
</blockquote></div>