Skip to content

Add annotations for various lock files - #610

Merged
asottile merged 1 commit into
mainfrom
lock-file-tags
Sep 26, 2026
Merged

asottile merged 1 commit into
mainfrom
lock-file-tags

Conversation

@mxr

@mxr mxr commented Sep 26, 2026

Copy link
Copy Markdown
Member

No description provided.

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like these shouldn't really be necessary with files: ... but shrugs

@asottile
asottile merged commit 971546c into main Sep 26, 2026
6 checks passed
@asottile
asottile deleted the lock-file-tags branch September 26, 2026 20:20
AndrewDongminYoo added a commit to AndrewDongminYoo/toml-tidy that referenced this pull request Oct 26, 2026
## Summary

The pre-commit hook selected files with `types: [toml]` only, and
pre-commit's `identify` tags `uv.lock`, `poetry.lock` and `Cargo.lock`
as `toml`, so the default hook configuration rewrote generated
lockfiles.
The hook now also declares `files: (?i)(\.toml|(^|/)Pipfile)$`;
pre-commit requires a file to match both `files` and `types`, so
lockfiles never reach it.
The README example drops its `exclude: ^uv\.lock$` workaround and states
the new default.

Closes #35

## Verification

Gates at `93ba676`:

- `uv run pytest` → exit 0 (231 passed, 3 skipped)
- `uv run ruff check src tests` → exit 0
- `uv run basedpyright` → exit 0
- `uv run ruff format --check src tests` → exit 0

`tests/test_hook_manifest.py` reads the `files` pattern from the
manifest and checks it with `re.search`, the way pre-commit filters
filenames.

End-to-end check with `uvx pre-commit try-repo <worktree> toml-tidy
--all-files` in scratch repositories, each fixture file holding unsorted
`b = 1` / `a = 2`:

| File | `--ref HEAD` (current main) | This branch |
| --- | --- | --- |
| `uv.lock`, `poetry.lock`, `Cargo.lock` | rewritten | unchanged |
| `Pipfile`, `nested/Pipfile` | rewritten | rewritten |
| `config.toml`, `nested/settings.toml`, `upper/CONFIG.TOML` | rewritten
| rewritten |

Local review: Small tier (3 files, 55 added lines, no change under
`src/`), reviewed inline against the issue.
The automated review flagged that a plain `\.toml$` narrowed coverage
beyond lockfiles (upper-case extensions and `Pipfile`, which `identify`
also tags as toml); both are kept by the final pattern.
The local Codex drain did not run because the machine was saturated
(load average above 100); the hosted review below covers the same head.

Hosted review: Codex code review and security review both completed with
no findings at `93ba676`, and CI passed at the same commit.
CodeRabbit skipped the automatic review because the repository has fewer
than 10 stars, so Codex was the only hosted reviewer.

## Decisions taken where the brief was silent

`exclude_types: [cargo-lock, poetry-lock, uv-lock]` is not used:
`identify` added the `uv-lock` and `poetry-lock` tags on 2026-09-26
(pre-commit/identify#610), and pre-commit's `check_type_tag` refuses to
load a hook naming a tag the installed `identify` does not know.
A regex `exclude` in the manifest is not used either, because a user's
own `exclude` replaces it, while `files` is rarely overridden.
`(?i)` keeps `.TOML` and `.Toml` files in scope, since `identify` tags
TOML extensions in any case; it sits at the start of the pattern because
Python 3.11+ rejects a global inline flag elsewhere.
`Pipfile` stays in scope because it is the only toml-tagged file name
that is neither a lockfile nor `*.toml`, and the hook already formatted
it.
`CHANGELOG.md` is left to the next release PR, as with recent feature
and fix PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants