public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Proposal: format GDB Python files with black
@ 2021-04-26 15:55 Simon Marchi
  2021-04-26 16:21 ` Andrew Burgess
                   ` (5 more replies)
  0 siblings, 6 replies; 28+ messages in thread
From: Simon Marchi @ 2021-04-26 15:55 UTC (permalink / raw)
  To: gdb-patches

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

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-05-13 17:13 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 15:55 Proposal: format GDB Python files with black Simon Marchi
2021-04-26 16:21 ` Andrew Burgess
2021-04-26 17:25   ` Simon Marchi
2021-04-26 17:50     ` Andrew Burgess
2021-04-26 18:08       ` Simon Marchi
2021-04-27  7:54         ` Andrew Burgess
2021-04-27 13:21           ` Simon Marchi
2021-04-26 17:42   ` Tom Tromey
2021-04-26 17:34 ` Paul Koning
2021-04-26 17:44   ` Simon Marchi
2021-04-26 17:48     ` Simon Marchi
2021-04-26 17:39 ` Tom Tromey
2021-04-30 16:26   ` Joel Brobecker
2021-04-26 22:40 ` Lancelot SIX
2021-04-30 17:04   ` Tom Tromey
2021-04-30 17:14     ` Simon Marchi
2021-05-01  6:42       ` Joel Brobecker
2021-04-30 17:21 ` Luis Machado
2021-05-08 16:00 ` Tom Tromey
2021-05-11  2:55   ` Simon Marchi
2021-05-11  2:57     ` Using clang-format Simon Marchi
2021-05-11 13:31       ` Marco Barisione
2021-05-11 13:44         ` Simon Marchi
2021-05-11 20:40       ` Tom Tromey
2021-05-13 17:13         ` Simon Marchi
2021-05-11 11:38     ` Proposal: format GDB Python files with black Luis Machado
2021-05-11 13:49       ` Simon Marchi
2021-05-11 14:23         ` Luis Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).