Skip to content

lachaib/uv-pre-commit

 
 

Repository files navigation

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 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.4.29
  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.4.29
  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.4.29
  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 ensure the lockfile is up-to-date:

- repo: https://github.com/astral-sh/uv-pre-commit
  # uv version.
  rev: 0.4.29
  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.4.29
  hooks:
    - id: uv-export

To export to an alternative file, modify the args:

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

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%