On 10/13/22 12:03, Richard Sandiford wrote: > Martin Liška <mli...@suse.cz> writes: >> I think we should add how Python scripts should be formatted. I noticed >> that while reading the Modula-2 patchset where it follows the C/C++ style >> when it comes to Python files. >> >> Ready to be installed? >> Thanks, >> Martin > > Did you consider requiring black formatting instead? Maybe black -l79 > to maintain the usual 80-character limit.
No, the automatic formatting might be a next step. About 80 chars, can we relax that for Python scripts? I think it's hairy restriction these days. > > At least that way there's only one right answer. Yep. We can definitely recommend using black as an optional approach, what do you think? Martin > > Richard > >> >> --- >> htdocs/codingconventions.html | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html >> index e4d30510..180ef35a 100644 >> --- a/htdocs/codingconventions.html >> +++ b/htdocs/codingconventions.html >> @@ -80,6 +80,7 @@ the conventions separately from any other changes to the >> code.</p> >> </li> >> </ul> >> </li> >> +<li><a href="#Python_Conventions">Python Language Conventions</a> >> </ul> >> >> >> @@ -1483,6 +1484,19 @@ with a right brace, optional closing comment, and a >> new line. >> Definitions within the body of a namespace are not indented. >> </p> >> >> +<h2 id="Python_Conventions">Python Language Conventions</h2> >> + >> +<p> >> +Python scripts should follow <a >> href="https://peps.python.org/pep-0008/">PEP 8 – Style Guide for Python >> Code</a> >> +which can be verified by <a href="flake8.pycqa.org">flake8</a> tool. >> +We do also recommend using the following <code>flake8</code> plug-ins: >> + >> +<ul> >> + <li>flake8-builtins</li> >> + <li>flake8-import-order</li> >> + <li>flake8-quotes</li> >> +</ul> >> +</p> >> >> </body> >> </html>