This is a simple Pre-Commit Hook that will compare your poetry.lock or uv.lock file with the additional dependencies included in .pre-commit-config.yaml. Any additional dependencies which are found in the lockfile will be pinned to that version within the PCH config.
Add this pre-commit hook to your project by adding the following to your .pre-commit-config.yaml:
- repo: https://github.com/worgarside/pre-commit-hooks-dependency-sync
rev: 1.0.1
hooks:
- id: sync-additional-dependenciesYou 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--pch-config-path/-c: Path to.pre-commit-config.yaml(default:.pre-commit-config.yamlin repo root)--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
- uv