MCPcopy Index your code
hub / github.com/astral-sh/uv-pre-commit

github.com/astral-sh/uv-pre-commit @0.11.26

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.11.26 ↗ · + Follow
6 symbols 20 edges 1 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

uv-pre-commit

uv image image image Actions status Discord

A pre-commit hook for uv.

Distributed as a standalone repository to enable installing uv via prebuilt wheels from PyPI.

Using uv with pre-commit

To ensure the lockfile is up-to-date:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    # Update the uv lockfile
    - id: uv-lock

To autoexport uv.lock to requirements.txt:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    - id: uv-export

By default, this hook uses the "quiet" output.

To export to an alternative file, modify the args:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    - id: uv-export
      args: ["--frozen", "--output-file=requirements-custom.txt", "--quiet"]

To compile your requirements via pre-commit, add the following to your .pre-commit-config.yaml:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    # Run the pip compile
    - id: pip-compile
      args: [requirements.in, -o, requirements.txt]

To compile alternative files, modify the args and files:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    # Run the pip compile
    - id: pip-compile
      args: [requirements-dev.in, -o, requirements-dev.txt]
      files: ^requirements-dev\.(in|txt)$

To run the hook over multiple files at the same time:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    # Run the pip compile
    - id: pip-compile
      name: pip-compile requirements.in
      args: [requirements.in, -o, requirements.txt]
    - id: pip-compile
      name: pip-compile requirements-dev.in
      args: [requirements-dev.in, -o, requirements-dev.txt]
      files: ^requirements-dev\.(in|txt)$

To run a hook on a project within a subdirectory (i.e., in a monorepo):

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    # Update the uv lockfile
    - id: uv-lock
      # Change <path/to/project> to your relative path
      files: <path/to/project>/pyproject.toml
      args: [--project, <path/to/project>]

To synchronize your dependencies upon branch checkout, pull or rebase:

default_install_hook_types:
  - pre-commit
  - post-checkout
  - post-merge
  - post-rewrite
repos:
  - repo: https://github.com/astral-sh/uv-pre-commit
    # uv version.
    rev: 0.11.26
    hooks:
      - id: uv-sync

In order to install this hook, you either need to specify default_install_hook_types (as above) and run pre-commit install, or you have to install it via pre-commit install --install-hooks -t post-checkout -t post-merge -t post-rewrite.

To synchronize all dependencies in a workspace:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    - id: uv-sync
      args: ["--locked", "--all-packages"]

If you use keyring to authenticate to a private index, include it as an additional sync dependency:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.11.26
  hooks:
    - id: uv-sync
      additional_dependencies: [keyring]

License

uv-pre-commit is licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in uv-pre-commit by you, as defined in the Apache-2.0 license, shall be dually licensed as above, without any additional terms or conditions.

Core symbols most depended-on inside this repo

main
called by 1
mirror.py
get_all_versions
called by 1
mirror.py
get_current_version
called by 1
mirror.py
process_version
called by 1
mirror.py
replace_pyproject_toml
called by 0
mirror.py
replace_readme_md
called by 0
mirror.py

Shape

Function 6

Languages

Python100%

Modules by API surface

mirror.py6 symbols

For agents

$ claude mcp add uv-pre-commit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page