This hook compares your poetry.lock or uv.lock file with the additional
dependencies in prek.toml, .pre-commit-config.yaml, or
.pre-commit-config.yml. Dependencies found in the lockfile are pinned to that
version in the hook config.
Add this hook to a pre-commit YAML config:
- repo: https://github.com/worgarside/pre-commit-hooks-dependency-sync
rev: 1.0.1
hooks:
- id: sync-additional-dependenciesOr add it to prek.toml:
[[repos]]
repo = "https://github.com/worgarside/pre-commit-hooks-dependency-sync"
rev = "1.0.1"
[[repos.hooks]]
id = "sync-additional-dependencies"When --config-path is omitted, config discovery follows prek's precedence:
prek.toml, .pre-commit-config.yaml, then .pre-commit-config.yml.
You can customize the behavior of the hook by passing arguments:
- repo: https://github.com/worgarside/pre-commit-hooks-dependency-sync
rev: 1.0.1
hooks:
- id: sync-additional-dependencies
args:
- --exclude-packages
- package-name-1
- package-name-2--config-path/-c: Path toprek.tomlor a pre-commit YAML config (default: discover using prek's precedence). The previous--pch-config-pathname remains supported.--hook-name/-n: Optional hook name to limit dependency updates to a specific hook--package-manager/-p: Package manager to use (poetryoruv, default:poetry)--lockfile-path/-l: Path to lockfile (default:<package-manager>.lockin repo root)--exclude-packages/-e: One or more package names to exclude from synchronization
If you want to prevent certain packages from being synchronized (e.g., to maintain a specific version):
- repo: https://github.com/worgarside/pre-commit-hooks-dependency-sync
rev: 1.0.1
hooks:
- id: sync-additional-dependencies
args:
- --exclude-packages
- mypy
- ruff - repo: https://github.com/worgarside/pre-commit-hooks-dependency-sync
rev: 1.0.1
hooks:
- id: sync-additional-dependencies
args:
- --package-manager
- uvThis project uses uv for dependency management and builds:
uv sync --locked
uv run sync-dependencies --package-manager uv --lockfile-path uv.lock
uv build