From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] [pre-commit] Remove duplication in config file
Date: Mon, 13 Jul 2026 13:14:58 +0200 [thread overview]
Message-ID: <50d9ac70-c824-4fd3-ba80-f9a16c40e919@suse.de> (raw)
In-Reply-To: <20260618074712.32860-1-tdevries@suse.de>
On 6/18/26 9:47 AM, Tom de Vries wrote:
> In a recent commit, I introduced anchor/alias pairs in
> .pre-commit-config.yaml, with short non-descriptive names for local use:
> ...
> - - id: check-include-guards
> - name: check-include-guards
> + - id: &id0 check-include-guards
> + name: *id0
> ...
>
> Use anchor and aliases a bit more to remove duplication, now using more
> descriptive names for non-local uses.
>
> Yaml also supports defining an anchor for more than one field, which result in
> cleaner code:
> ...
> +python-files: &python-files
> + types_or: [file]
> + files: '^gdb/.*\.py(\.in)?$'
> +
> ...
> - id: black
> - types_or: [file]
> - files: '^gdb/.*\.py(\.in)?$'
> + <<: *python-files
> ...
> but unfortunately pre-commit generates a warning "[WARNING] Unexpected key(s)
> present at root: python-files" for this [1].
>
> Also add a default files setting.
>
I've pushed this.
Thanks,
- Tom
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34295
>
> [1] https://github.com/pre-commit/pre-commit/issues/1481
> ---
> .pre-commit-config.yaml | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
> index 141451501ed..c15a1c64690 100644
> --- a/.pre-commit-config.yaml
> +++ b/.pre-commit-config.yaml
> @@ -40,6 +40,7 @@
> minimum_pre_commit_version: 4.5.1
> default_install_hook_types: [pre-commit, commit-msg]
> default_stages: [pre-commit]
> +files: '^(gdb|gdbserver|gdbsupport)/'
>
> repos:
> # Python hooks. Run these for (in glob notation):
> @@ -56,33 +57,32 @@ repos:
> rev: 26.5.1
> hooks:
> - id: black
> - types_or: [file]
> - files: '^gdb/.*\.py(\.in)?$'
> + types_or: &gdb_python_types [file]
> + files: &gdb_python_files '^gdb/.*\.py(\.in)?$'
> - repo: https://github.com/pycqa/flake8
> rev: 7.3.0
> hooks:
> - id: flake8
> - types_or: [file]
> - files: '^gdb/.*\.py(\.in)?$'
> + types_or: *gdb_python_types
> + files: *gdb_python_files
> args: [--config, gdb/setup.cfg]
> - repo: https://github.com/pycqa/isort
> rev: 9.0.0a3
> hooks:
> - id: isort
> - types_or: [file]
> - files: '^gdb/.*\.py(\.in)?$'
> + types_or: *gdb_python_types
> + files: *gdb_python_files
>
> # Codespell hooks.
> - repo: https://github.com/codespell-project/codespell
> rev: v2.4.2
> hooks:
> - id: codespell
> - files: '^(gdb|gdbserver|gdbsupport)/'
> - args: [--toml, gdb/pyproject.toml]
> + args: &codespell_args [--toml, gdb/pyproject.toml]
> - id: codespell
> name: codespell-log
> entry: gdb/contrib/codespell-log.sh
> - args: [--toml, gdb/pyproject.toml]
> + args: *codespell_args
> verbose: true
> stages: [commit-msg]
>
> @@ -116,7 +116,6 @@ repos:
> name: *id2
> language: unsupported_script
> entry: gdb/contrib/check-whitespace-pre-commit.py
> - files: '^(gdb(support|server)?)/.*$'
> - id: &id3 pre-commit-setup
> name: *id3
> language: python
> @@ -128,4 +127,3 @@ repos:
> name: *id4
> language: unsupported_script
> entry: gdb/contrib/check-file-mode.sh
> - files: '^(gdb|gdbserver|gdbsupport)/.*$'
>
> base-commit: 0c6ebc781ac79cd64d12d8acc1cb50fd4de2bb3a
prev parent reply other threads:[~2026-07-13 11:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 7:47 Tom de Vries
2026-07-13 11:14 ` Tom de Vries [this message]
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=50d9ac70-c824-4fd3-ba80-f9a16c40e919@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