From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/5] [pre-commit] Run flake8 for gdb/gdb-gdb.py.in
Date: Mon, 20 Jul 2026 14:50:54 +0200 [thread overview]
Message-ID: <20260720125056.1373177-4-tdevries@suse.de> (raw)
In-Reply-To: <20260720125056.1373177-1-tdevries@suse.de>
When running the pre-commit hooks for gdb/gdb-gdb.py.in:
...
$ pre-commit run --files gdb/gdb-gdb.py.in
black...................................................................Passed
flake8..............................................(no files to check)Skipped
isort...................................................................Passed
codespell...............................................................Passed
tclint..............................................(no files to check)Skipped
check-include-guards................................(no files to check)Skipped
check-gnu-style.....................................(no files to check)Skipped
- hook id: check-gnu-style
check-whitespace........................................................Passed
pre-commit-setup........................................................Passed
check-file-mode.........................................................Passed
...
we see that flake8 is skipped.
The hook setup has a types_or workaround that's supposed to prevent this:
...
- id: flake8
types_or: *gdb_python_types
files: *gdb_python_files
args: [--config, gdb/setup.cfg]
...
but that doesn't work because flake8's .pre-commit-hooks.yaml doesn't set
types_or, but types:
...
types: [python]
...
So we end up with an effective setting of both types and types_or:
...
types: [python]
types_or: [file]
...
which both have to be matched, and because gdb/gdb-gdb.py.in doesn't match
python:
...
$ identify-cli gdb/gdb-gdb.py.in
["file", "non-executable", "text"]
...
the file is skipped.
This could be fixed by:
...
- types_or: [file]
+ types: [file]
...
but an isort update setting types_or could reintroduce the same problem.
For robustness, fix this by setting both types and types_or for each python
hook.
Using the same value for both settings would work:
...
types: [file]
types_or: [file]
...
because types and types_or have the same effect for list lengths 0 and 1.
But I think it's better to have different anchors to avoid any confusion about
the and/or behavior, in which case it's more natural to use the actual default
[] for types_or, and to update the anchor names to reflect that these are the
default values:
...
types: &types_default [file]
types_or: &types_or_default []
...
---
.pre-commit-config.yaml | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 60164e446fc..b437593b228 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -53,26 +53,33 @@ repos:
# - gdb/testsuite/*.py
#
# Because gdb/gdb-gdb.py.in is not classified as python, we use
- # 'types_or: [file]' to override the default type for these hooks.
+ # 'types: [file] / types_or: []' to override the default settings for these
+ # hooks.
+ #
+ # To be robust we set both types and types_or for each hook. Typically a
+ # repo sets only one of these, but that may change with any update.
#
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
- types_or: &gdb_python_types [file]
+ types: &types_default [file]
+ types_or: &types_or_default []
files: &gdb_python_files '^gdb/.*\.py(\.in)?$'
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
hooks:
- id: flake8
- types_or: *gdb_python_types
+ types: *types_default
+ types_or: *types_or_default
files: *gdb_python_files
args: [--config, gdb/setup.cfg]
- repo: https://github.com/pycqa/isort
rev: 9.0.0b1
hooks:
- id: isort
- types_or: *gdb_python_types
+ types: *types_default
+ types_or: *types_or_default
files: *gdb_python_files
# Isort's .pre-commit-hooks.yaml sets stages, overriding default_stages,
# so this hook needs an explicit setting.
--
2.51.0
next prev parent reply other threads:[~2026-07-20 12:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 12:50 [PATCH 0/5] [pre-commit] Some pre-commit improvements Tom de Vries
2026-07-20 12:50 ` [PATCH 1/5] [gdb] Fix bare except in gdb/gdb-gdb.py.in Tom de Vries
2026-07-20 12:50 ` [PATCH 2/5] [gdb] Remove superfluous global " Tom de Vries
2026-07-20 12:50 ` Tom de Vries [this message]
2026-07-20 12:50 ` [PATCH 4/5] [pre-commit] Don't require text type for check-whitespace hook Tom de Vries
2026-07-20 12:50 ` [PATCH 5/5] [pre-commit] Don't require text type for codespell hook Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260720125056.1373177-4-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox