]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
pre-commit: run flake8 on more Python files
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 5 Dec 2024 17:41:21 +0000 (12:41 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 4 Feb 2025 17:59:49 +0000 (12:59 -0500)
pre-commit currently runs flake8 only on `gdb/python/**/*.py`.  There
are more files we can run it on, without running it on all the testsuite
files.  Add:

 - gdb/gdb-gdb.py.in
 - gdb/*.py
 - gdb/testsuite/*.py

Fix the new errors that popped up:

    gdb/copyright.py:29:21: W605 invalid escape sequence '\*'
    gdb/copyright.py:29:29: W605 invalid escape sequence '\*'
    gdb/copyright.py:29:38: W605 invalid escape sequence '\*'
    gdb/copyright.py:29:46: W605 invalid escape sequence '\*'
    gdb/copyright.py:34:1: F401 'datetime' imported but unused
    gdb/testsuite/analyze-racy-logs.py:150:9: E722 do not use bare 'except'

Change-Id: Ia864c22d4f170d4e18ce3beb06a86c49966654b2
Approved-By: Tom Tromey <tom@tromey.com>
.pre-commit-config.yaml
gdb/copyright.py
gdb/testsuite/analyze-racy-logs.py

index 29f7f6415e0b21891d07932f6bee34b287c6a39d..eed31d7d54bba9af4627203f00fe1748a0a3ad40 100644 (file)
@@ -49,9 +49,14 @@ repos:
     hooks:
     - id: flake8
       types_or: [file]
-      # Note this one is only run on gdb/python, not (for now) the
-      # test suite.
-      files: 'gdb/python/.*\.py(\.in)?$'
+      # Run this for (in glob notation):
+      #
+      #  - gdb/gdb-gdb.py.in
+      #  - gdb/*.py
+      #  - gdb/python/**/*.py
+      #  - gdb/testsuite/*.py
+      #
+      files: '^gdb/(gdb-gdb\.py\.in|[^/]+\.py|python/.+\.py|testsuite/[^/]+\.py)$'
       args: [--config, gdb/setup.cfg]
   - repo: https://github.com/pycqa/isort
     rev: 6.0.0
index 2c9ea3c1d591f3b847d60a5d6a9195aa7bd2ef58..1a155b9cc83171105b74959be180ca9cb9d2ff3b 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-"""copyright.py
-
-This script updates the list of years in the copyright notices in
-most files maintained by the GDB project.
-
-Usage: cd src/gdb && ./copyright.py
-
-Always review the output of this script before committing it!
-A useful command to review the output is:
-    % filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff
-This removes the bulk of the changes which are most likely to be correct.
-"""
+# This script updates the list of years in the copyright notices in
+# most files maintained by the GDB project.
+#
+# Usage: cd src/gdb && ./copyright.py
+#
+# Always review the output of this script before committing it!
+#
+# A useful command to review the output is:
+#
+#     $ filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff
+#
+# This removes the bulk of the changes which are most likely to be correct.
 
 import argparse
-import datetime
 import locale
 import os
 import os.path
index 5a3f90ed62d025766b35f5595097958191e3cd17..3863bd07b2860f21a5022fab78a488cb9b419c9b 100755 (executable)
@@ -147,7 +147,7 @@ def identify_racy_tests():
     for s1, s2 in ignore_relations.items():
         try:
             ignored_tests |= all_tests[s1] & all_tests[s2]
-        except:
+        except Exception:
             continue
 
     racy_tests: set[str] = set()