gdb: re-format Python files using black 21.4b0
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 14:56:20 +0000 (10:56 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 14:56:20 +0000 (10:56 -0400)
commit13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d
treeec33a85ccb58f44445608d0cab68020fa588cb74
parenta9b49cbcd5935a713da5715799ea3b24e0a52851
gdb: re-format Python files using black 21.4b0

Re-format all Python files using black [1] version 21.4b0.  The goal is
that from now on, we keep all Python files formatted using black.  And
that we never have to discuss formatting during review (for these files
at least) ever again.

One change is needed in gdb.python/py-prettyprint.exp, because it
matches the string representation of an exception, which shows source
code.  So the change in formatting must be replicated in the expected
regexp.

To document our usage of black I plan on adding this to the "GDB Python
Coding Standards" wiki page [2]:

--8<--

All Python source files under the `gdb/` directory must be formatted
using black version 21.4b0.

This specific version can be installed using:

    $ pip3 install 'black == 21.4b0'

All you need to do to re-format files is run `black <file/directory>`,
and black will re-format any Python file it finds in there.  It runs
quite fast, so the simplest is to do:

    $ black gdb/

from the top-level.

If you notice that black produces changes unrelated to your patch, it's
probably because someone forgot to run it before you.  In this case,
don't include unrelated hunks in your patch.  Push an obvious patch
fixing the formatting and rebase your work on top of that.

-->8--

Once this is merged, I plan on setting a up an `ignoreRevsFile`
config so that git-blame ignores this commit, as described here:

  https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame

I also plan on working on a git commit hook (checked in the repo) to
automatically check the formatting of the Python files on commit.

[1] https://pypi.org/project/black/
[2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards

gdb/ChangeLog:

* Re-format all Python files using black.

gdb/testsuite/ChangeLog:

* Re-format all Python files using black.
* gdb.python/py-prettyprint.exp (run_lang_tests): Adjust.

Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919
84 files changed:
gdb/ChangeLog
gdb/contrib/test_pubnames_and_indexes.py
gdb/copyright.py
gdb/python/lib/gdb/FrameDecorator.py
gdb/python/lib/gdb/FrameIterator.py
gdb/python/lib/gdb/__init__.py
gdb/python/lib/gdb/command/__init__.py
gdb/python/lib/gdb/command/explore.py
gdb/python/lib/gdb/command/frame_filters.py
gdb/python/lib/gdb/command/pretty_printers.py
gdb/python/lib/gdb/command/prompt.py
gdb/python/lib/gdb/command/type_printers.py
gdb/python/lib/gdb/command/unwinders.py
gdb/python/lib/gdb/command/xmethods.py
gdb/python/lib/gdb/frames.py
gdb/python/lib/gdb/function/as_string.py
gdb/python/lib/gdb/function/caller_is.py
gdb/python/lib/gdb/function/strfns.py
gdb/python/lib/gdb/printer/bound_registers.py
gdb/python/lib/gdb/printing.py
gdb/python/lib/gdb/prompt.py
gdb/python/lib/gdb/types.py
gdb/python/lib/gdb/unwinder.py
gdb/python/lib/gdb/xmethod.py
gdb/python/python-config.py
gdb/syscalls/arm-linux.py
gdb/system-gdbinit/elinos.py
gdb/system-gdbinit/wrs-linux.py
gdb/testsuite/ChangeLog
gdb/testsuite/analyze-racy-logs.py
gdb/testsuite/gdb.ada/pp-rec-component.py
gdb/testsuite/gdb.perf/backtrace.py
gdb/testsuite/gdb.perf/disassemble.py
gdb/testsuite/gdb.perf/gmonster-null-lookup.py
gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
gdb/testsuite/gdb.perf/gmonster-print-cerr.py
gdb/testsuite/gdb.perf/gmonster-ptype-string.py
gdb/testsuite/gdb.perf/gmonster-runto-main.py
gdb/testsuite/gdb.perf/gmonster-select-file.py
gdb/testsuite/gdb.perf/lib/perftest/measure.py
gdb/testsuite/gdb.perf/lib/perftest/perftest.py
gdb/testsuite/gdb.perf/lib/perftest/reporter.py
gdb/testsuite/gdb.perf/lib/perftest/testresult.py
gdb/testsuite/gdb.perf/lib/perftest/utils.py
gdb/testsuite/gdb.perf/single-step.py
gdb/testsuite/gdb.perf/skip-command.py
gdb/testsuite/gdb.perf/skip-prologue.py
gdb/testsuite/gdb.perf/solib.py
gdb/testsuite/gdb.perf/template-breakpoints.py
gdb/testsuite/gdb.python/py-auto-load-chaining-f1.o-gdb.py
gdb/testsuite/gdb.python/py-auto-load-chaining-f2.o-gdb.py
gdb/testsuite/gdb.python/py-bad-printers.py
gdb/testsuite/gdb.python/py-breakpoint-create-fail.py
gdb/testsuite/gdb.python/py-completion.py
gdb/testsuite/gdb.python/py-error.py
gdb/testsuite/gdb.python/py-events.py
gdb/testsuite/gdb.python/py-finish-breakpoint.py
gdb/testsuite/gdb.python/py-finish-breakpoint2.py
gdb/testsuite/gdb.python/py-format-string.py
gdb/testsuite/gdb.python/py-frame-args.py
gdb/testsuite/gdb.python/py-framefilter-addr.py
gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
gdb/testsuite/gdb.python/py-framefilter.py
gdb/testsuite/gdb.python/py-mi-events-gdb.py
gdb/testsuite/gdb.python/py-mi-var-info-path-expression.py
gdb/testsuite/gdb.python/py-nested-maps.py
gdb/testsuite/gdb.python/py-objfile-script-gdb.py
gdb/testsuite/gdb.python/py-pp-integral.py
gdb/testsuite/gdb.python/py-pp-maint.py
gdb/testsuite/gdb.python/py-pp-re-notag.py
gdb/testsuite/gdb.python/py-pp-registration.py
gdb/testsuite/gdb.python/py-prettyprint.exp
gdb/testsuite/gdb.python/py-prettyprint.py
gdb/testsuite/gdb.python/py-recurse-unwind.py
gdb/testsuite/gdb.python/py-section-script.py
gdb/testsuite/gdb.python/py-typeprint.py
gdb/testsuite/gdb.python/py-unwind-inline.py
gdb/testsuite/gdb.python/py-unwind-maint.py
gdb/testsuite/gdb.python/py-unwind.py
gdb/testsuite/gdb.python/py-xmethods.py
gdb/testsuite/gdb.python/source2.py
gdb/testsuite/gdb.python/tui-window-disabled.py
gdb/testsuite/gdb.python/tui-window.py
gdb/testsuite/print-ts.py