Skip to content

Conversation

@wpk-nist-gov
Copy link

@wpk-nist-gov wpk-nist-gov commented Jun 13, 2025

This adds a uv-run hook. This allows, for example, using pre-commit to call scripts with inline metadata.

I made this PR before I saw #42. The hooks are the same, but this PR includes snippet in the README.md. Closes #37 and #14.

Note that I considered also adding a uv-tool-run hook, but if someone want to do that, they can just override entry with something like

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: ...
  hooks:
    - id: uv-run
      entry: uvx tool ...

@danielhollas danielhollas mentioned this pull request Aug 12, 2025
1 task
@jenshnielsen
Copy link

@wpk-nist-gov @zanieb This looks super useful. Is there anything I can do to help make this land?

zanieb and others added 9 commits November 13, 2025 09:40
Hi,

First time interacting with a `astral-sh` repo, so first of all thank
you very much for developing amazing tools like `uv` an `ruff`. :)

In this PR, I am proposing to use the quiet output by default in the
`uv-export` hook.
Currently the hook will also print the whole export. This output (which
also includes hashes) that can quickly become very very long and
therefore it makes it harder to inspect the rest of `pre-commit`
results.
IMO verbose outputs in `pre-commit` hooks make sense when they show
specific actionable errors (e.g. `ruff` or typing errors). In this case,
the hook could simplify just fail and regenerate the file:

```console
$ pre-commit run --all-files
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
check json...............................................................Passed
check for merge conflicts................................................Passed
check for added large files..............................................Passed
debug statements (python)................................................Passed
detect private key.......................................................Passed
ruff.....................................................................Passed
uv-export................................................................Failed
- hook id: uv-export
- files were modified by this hook
```

This is a bit of personal preference I guess, so happy to close this PR
if you don't agree :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add uv-run hook

6 participants