From 13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 7 May 2021 10:56:20 -0400 Subject: 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 `, 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 --- gdb/testsuite/gdb.perf/lib/perftest/reporter.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'gdb/testsuite/gdb.perf/lib/perftest/reporter.py') diff --git a/gdb/testsuite/gdb.perf/lib/perftest/reporter.py b/gdb/testsuite/gdb.perf/lib/perftest/reporter.py index 8617413a5a4..5569ece6c13 100644 --- a/gdb/testsuite/gdb.perf/lib/perftest/reporter.py +++ b/gdb/testsuite/gdb.perf/lib/perftest/reporter.py @@ -57,29 +57,30 @@ class TextReporter(Reporter): """Report results in a plain text file 'perftest.log'.""" def __init__(self, append): - super (TextReporter, self).__init__(Reporter(append)) + super(TextReporter, self).__init__(Reporter(append)) self.txt_sum = None self.txt_log = None def report(self, test_name, measurement_name, data_points): if len(data_points) == 0: - self.txt_sum.write("%s %s *no data recorded*\n" % ( - test_name, measurement_name)) + self.txt_sum.write( + "%s %s *no data recorded*\n" % (test_name, measurement_name) + ) return average = sum(data_points) / len(data_points) data_min = min(data_points) data_max = max(data_points) - self.txt_sum.write("%s %s %s\n" % ( - test_name, measurement_name, average)) - self.txt_log.write("%s %s %s, min %s, max %s, data %s\n" % ( - test_name, measurement_name, average, data_min, data_max, - data_points)) + self.txt_sum.write("%s %s %s\n" % (test_name, measurement_name, average)) + self.txt_log.write( + "%s %s %s, min %s, max %s, data %s\n" + % (test_name, measurement_name, average, data_min, data_max, data_points) + ) def start(self): mode = "a+" if self.append else "w" - self.txt_sum = open (SUM_FILE_NAME, mode); - self.txt_log = open (LOG_FILE_NAME, mode); + self.txt_sum = open(SUM_FILE_NAME, mode) + self.txt_log = open(LOG_FILE_NAME, mode) def end(self): - self.txt_sum.close () - self.txt_log.close () + self.txt_sum.close() + self.txt_log.close() -- cgit v1.2.1