Message ID | d77b6541-1a2a-f15d-6855-14e206081fa4@suse.cz |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp176427wrs; Thu, 13 Oct 2022 02:38:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6U8O6ndFLR+WeYxaLGuHE3xT1uPWrx3G/bE2VF3+eIeGXs+sz5cURYkNrwk/L6hkKgsfhZ X-Received: by 2002:aa7:c60a:0:b0:458:d707:117 with SMTP id h10-20020aa7c60a000000b00458d7070117mr32034015edq.258.1665653898128; Thu, 13 Oct 2022 02:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665653898; cv=none; d=google.com; s=arc-20160816; b=alsSLjMsG38vUYkX5KZ8gb81yKi2uPq0Sv21rCQgdgTBfbrXhstGKfhwpDNG7BlG/g qz2mhevuI1hovTtW5ONmshgCvX1c76xb5rWoD9LKndJccW3J5g2qmLPV8Yy91CwCwQlY R9Owv7e+4AEdk9x0FnQo4DntaOBpL6iDK1W3BJct+0ursGX/6dPute5fHSuAaYctgGEW 5b3Pdo+iLh6Y0K2qToi7QT8oIIkuM3+LpQyzfv6jM9zEBQp40w6uJ/gB+yl3jgkZOlF2 XK1ltASfttQ5Ids8neUJhNN5iJuITzIaVOlE2vJLfWy0DT6c/ScC9JMbWStW7rQhhO16 e3Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=KKEHhnnGaKyS60rWGbmf+yPqMwS8XxLnFNs3nNBzHP0=; b=acWXtZ/lXbnLQq3EzRt3SY0zz4REZPbH43QOUPusiZvfpXWWo08+NcBmN8VmTpPOFK L4AMKyxZnGGCpjr0RAlaenQPhOsvOMGEwiWfzNT8CmNcKm+FtHJwgUMe2dqflQsaM70/ UZxkZF5uch26pid7HdE3XjdhZ8KUZMMs9trJ4FuoCI2jne62yjiQaLWAoaW2dpuvC73U El7ze+Vo+SWzyzPdX0qJ+lzXpzIPVtptMpNTAAT8wCCjypCmNnEU1wSkp8hMsRk/aNM8 NMShkB23rzvdTwvLG6VVO9cNzwWqcVf+gDyeI7EXxkun3Em8tTJQgnr8nDsCyN7EWUW6 K3kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@suse.cz header.s=susede2_rsa header.b=Gf014oPU; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=oTkMReSC; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 21-20020a170906309500b0076f077cec04si16610062ejv.365.2022.10.13.02.38.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 02:38:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@suse.cz header.s=susede2_rsa header.b=Gf014oPU; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=oTkMReSC; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6390382E29E for <ouuuleilei@gmail.com>; Thu, 13 Oct 2022 09:38:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 7A7D3385116B for <gcc-patches@gcc.gnu.org>; Thu, 13 Oct 2022 09:37:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A7D3385116B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4A2821F385; Thu, 13 Oct 2022 09:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1665653868; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KKEHhnnGaKyS60rWGbmf+yPqMwS8XxLnFNs3nNBzHP0=; b=Gf014oPU/Jf0MXV45map4fXtvPMdL6OId7gKCfRp+gVtCqqROnPHXSE1feEkOiILOsAWKX 0C1z/iL1CFBwXnWS65Xlf03q3B+O2tYh82nx0iPY57fey+acjGTzv/mTPFL8Z13md1qSBl ZmN5uUfYz0+nm6F6u9VGnSeRpv267Kc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1665653868; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KKEHhnnGaKyS60rWGbmf+yPqMwS8XxLnFNs3nNBzHP0=; b=oTkMReSCjDdjQF1GHEpSaZO6W31D/Jl75SoY4I/dxbQ373tBveQ93S+9n1omE07c8dRSRS ylIVFO16s8vFb6BQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 17DB8139F3; Thu, 13 Oct 2022 09:37:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yNuXBGzcR2N+FgAAMHmgww (envelope-from <mliska@suse.cz>); Thu, 13 Oct 2022 09:37:48 +0000 Message-ID: <d77b6541-1a2a-f15d-6855-14e206081fa4@suse.cz> Date: Thu, 13 Oct 2022 11:37:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz> Subject: [DOCS] Python Language Conventions To: gcc-patches@gcc.gnu.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746564701708562660?= X-GMAIL-MSGID: =?utf-8?q?1746564701708562660?= |
Series |
[DOCS] Python Language Conventions
|
|
Commit Message
Martin Liška
Oct. 13, 2022, 9:37 a.m. UTC
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 --- htdocs/codingconventions.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Comments
Hi Martin, On Thu, 13 Oct 2022, Martin Liška wrote: > 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. good initiative, thank you! This makes sense to me, alas I'm not a Python hacker, so best wait to see what David and Gaius think, too? Some suggestions on the web side of things: > +<li><a href="#Python_Conventions">Python Language Conventions</a> Since the name of the page already is codingconventions.html, I suggest making this simply "#python" - shorter and simpler. :-) > +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. ...by the...tool. > +We do also recommend using the following <code>flake8</code> plug-ins: Here maybe simply say "We recommend using"? Hope this helps, Gerald
Martin Liška <mliska@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. At least that way there's only one right answer. 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>
On 10/13/22 12:03, Richard Sandiford wrote: > Martin Liška <mliska@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>
Martin Liška <mliska@suse.cz> writes: > On 10/13/22 12:03, Richard Sandiford wrote: >> Martin Liška <mliska@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. In practice it seems to work well, even at 79 chars. The default is 88 and I don't think the extra 8 or 9 columns are enough to make a different rule for Python worth it. FWIW, personally I use an 80-column editor for GCC stuff, and it would be a pain to have to switch to something different to work on Python. >> 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? IMO the real value is if it's the defined approach, rather than an optional approach. It's "format and forget", just like with clang-format. Thanks, Richard
On Thu, 2022-10-13 at 11:44 +0200, Gerald Pfeifer wrote: > Hi Martin, > > On Thu, 13 Oct 2022, Martin Liška wrote: > > 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. > > good initiative, thank you! This makes sense to me, alas I'm not a > Python > hacker, so best wait to see what David and Gaius think, too? I'm very much +1 on recommending PEP 8. My Python skills are bit-rotting somewhat, and I've not used flake8, but it seems a reasonable recommendation to me. > > > Some suggestions on the web side of things: > > > +<li><a href="#Python_Conventions">Python Language Conventions</a> > > Since the name of the page already is codingconventions.html, I > suggest > making this simply "#python" - shorter and simpler. :-) > > > +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. > > ...by the...tool. > > > +We do also recommend using the following <code>flake8</code> plug- > > ins: > > Here maybe simply say "We recommend using"? That's a much better wording. Dave > > Hope this helps, > Gerald
David Malcolm <dmalcolm@redhat.com> writes: > On Thu, 2022-10-13 at 11:44 +0200, Gerald Pfeifer wrote: >> Hi Martin, >> >> On Thu, 13 Oct 2022, Martin Liška wrote: >> > 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. >> >> good initiative, thank you! This makes sense to me, alas I'm not a >> Python >> hacker, so best wait to see what David and Gaius think, too? > > I'm very much +1 on recommending PEP 8. hi, all sounds very sensible - yes I'm also happy to adopt any house style and will reformat the code accordingly regards, Gaius
On 10/13/22 19:16, David Malcolm wrote: > On Thu, 2022-10-13 at 11:44 +0200, Gerald Pfeifer wrote: >> Hi Martin, >> >> On Thu, 13 Oct 2022, Martin Liška wrote: >>> 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. >> >> good initiative, thank you! This makes sense to me, alas I'm not a >> Python >> hacker, so best wait to see what David and Gaius think, too? > > I'm very much +1 on recommending PEP 8. > > My Python skills are bit-rotting somewhat, and I've not used flake8, > but it seems a reasonable recommendation to me. All right, let me install my initial patch with the improved wording. Cheers, Martin > >> >> >> Some suggestions on the web side of things: >> >>> +<li><a href="#Python_Conventions">Python Language Conventions</a> >> >> Since the name of the page already is codingconventions.html, I >> suggest >> making this simply "#python" - shorter and simpler. :-) >> >>> +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. >> >> ...by the...tool. >> >>> +We do also recommend using the following <code>flake8</code> plug- >>> ins: >> >> Here maybe simply say "We recommend using"? > > That's a much better wording. > > Dave > >> >> Hope this helps, >> Gerald >
On Mon, 17 Oct 2022, Martin Liška wrote:
> All right, let me install my initial patch with the improved wording.
The validator noticed a small issue which I addressed thusly (by
moving up the </p> - the beginning of <ul> implicitly closes a <p>).
No worries - that's what validators are for. :-)
Gerald
commit e9164572d233645b51ed8fa27729a52a0e242984
Author: Gerald Pfeifer <gerald@pfeifer.com>
Date: Thu Oct 20 13:04:48 2022 +0200
codingconventions: Fix markup
diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html
index 9d0a3f14..f88ef019 100644
--- a/htdocs/codingconventions.html
+++ b/htdocs/codingconventions.html
@@ -1486,17 +1486,15 @@ Definitions within the body of a namespace are not indented.
<h2 id="python">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>
+<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 the <a href="flake8.pycqa.org">flake8</a> tool.
-We recommend using the following <code>flake8</code> plug-ins:
+We recommend using the following <code>flake8</code> plug-ins:</p>
<ul>
<li>flake8-builtins</li>
<li>flake8-import-order</li>
<li>flake8-quotes</li>
</ul>
-</p>
</body>
</html>
On 10/20/22 13:34, Gerald Pfeifer wrote: > On Mon, 17 Oct 2022, Martin Liška wrote: >> All right, let me install my initial patch with the improved wording. > > The validator noticed a small issue which I addressed thusly (by > moving up the </p> - the beginning of <ul> implicitly closes a <p>). > > No worries - that's what validators are for. :-) Heh ;) Thanks for the fix. Martin > > Gerald > > commit e9164572d233645b51ed8fa27729a52a0e242984 > Author: Gerald Pfeifer <gerald@pfeifer.com> > Date: Thu Oct 20 13:04:48 2022 +0200 > > codingconventions: Fix markup > > diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html > index 9d0a3f14..f88ef019 100644 > --- a/htdocs/codingconventions.html > +++ b/htdocs/codingconventions.html > @@ -1486,17 +1486,15 @@ Definitions within the body of a namespace are not indented. > > <h2 id="python">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> > +<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 the <a href="flake8.pycqa.org">flake8</a> tool. > -We recommend using the following <code>flake8</code> plug-ins: > +We recommend using the following <code>flake8</code> plug-ins:</p> > > <ul> > <li>flake8-builtins</li> > <li>flake8-import-order</li> > <li>flake8-quotes</li> > </ul> > -</p> > > </body> > </html>
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>