From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E79273846075 for ; Mon, 26 Apr 2021 15:55:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E79273846075 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 13QFtLM4028061 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 26 Apr 2021 11:55:26 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 13QFtLM4028061 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7B5171E01F for ; Mon, 26 Apr 2021 11:55:21 -0400 (EDT) To: gdb-patches@sourceware.org From: Simon Marchi Subject: Proposal: format GDB Python files with black Message-ID: Date: Mon, 26 Apr 2021 11:55:21 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 26 Apr 2021 15:55:21 +0000 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Apr 2021 15:55:28 -0000 Hi all, A few people I talked to about this and I have good experience with the tool black to auto-format Python code. It is simple to use, fast and reliable (if it detects that it changed the meaning of the program by mistake, internal-errors out). I don't think I need to spell out the advantage of using such a tool, but just in case: it removes all the overhead of thinking about formatting when writing or reviewing code. My suggestion would be to format our code with black all at once. The typical counter-argument to this is "it will be harder to use git-blame". I don't think this is true, because you need to be able to skip over commits anyway, and it's trivial to skip over a commit when git-blaming using an interactive tool. But it's also possible to tell git to ignore certain commits when git-blaming [2], so we can do that. I think the output of black is quite readable. When it does weird stuff, it's generally because the lines / expressions are two long anyway, and deserve to be split in multiple lines / expressions. Here's a branch that shows how it would look like: https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/simark/black If the feedback is overall positive, I'll send a more format patch. Simon [1] https://github.com/psf/black [2] https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame