Skip to content

Pre-commit Snippet: Exclude hub_fetch_run.py From a Repo's Own ruff, With force-exclude #4243

Closed

Description

@ptr727

Problem

catalog/snippets/pre-commit/README.md and the snippet's own header say a build-profile repo with a uv.lock may swap a ruff hook's entry for uv run <tool>. That runs the repository's own ruff config, and the snippet tells the repo to copy hub_fetch_run.py beside the config. Nothing tells it to keep ruff off that copy.

A repository whose ruff config is stricter than the hub's then has the hook lint, autofix, and reformat the carried helper whenever a commit stages it. Take a repository with this config:

[tool.ruff]
line-length = 120

[tool.ruff.lint]
select = ["E", "W", "F", "RUF"]

Staging the copied hub_fetch_run.py and committing makes ruff check --fix remove its # noqa: BLE001 (RUF100). It reports a docstring line over 120 columns (E501), and ruff format rewraps two calls. The commit then fails, and the working copy is no longer byte-identical to the snippet. A repo-wide ruff check . in CI fails on the same file.

extend-exclude = ["hub_fetch_run.py"] alone does not fix it. pre-commit passes staged files to ruff by name, and ruff ignores its exclude settings for an explicitly named path unless force-exclude = true is set.

Proposed Change

The pre-commit snippet README, and the snippet header's uv run note, should state that a repository running ruff under its own config excludes the helper with both settings:

[tool.ruff]
extend-exclude = ["hub_fetch_run.py"]
force-exclude = true

The same applies to a .ruff.toml. RESYNC.md's step that copies the helper could carry the same line.

Found In

The aiopurpleair adoption of hub_fetch_run.py (ptr727/aiopurpleair#303), where the first commit attempt rewrote the helper before the exclude was added.

Activity

  1. added
    documentation
    on Nov 17, 2026
  2. added a commit that references this issue on Nov 17, 2026
    d296bfe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions