Skip to content

Commit d0aca38

Browse files
authored
Automatically resolve pylock if check fails (#299)
## Summary <!-- Include a short paragraph of the changes introduced in this PR. If this PR requires additional context or rationale, explain why the changes are necessary. --> Currently if the package requirements change in `pyproject.toml` the pylock pre-commit hook will fail and require the user to manually apply a pylock update. This change automates the pylock update so the user should only need to add and commit the updated pylock. ## Details <!-- Provide a detailed list of all changes introduced in this pull request. --> - Update pylock pre-commit hook to attempt to update the pylock file when `pdm lock --check` fails. ## Test Plan <!-- List the steps needed to test this PR. --> 1. Adjust package dependencies in `pyproject.toml` 2. Run `pdm run pre-commit run pdm-lock-check --all-files` and validate that the pylock changed 4. Run `pdm run pre-commit run pdm-lock-check --all-files` and validate that the check passes --- - [x] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [ ] Includes AI-assisted code completion - [ ] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`) Signed-off-by: Samuel Monson <[email protected]>
1 parent 0e3966b commit d0aca38

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repos:
1111
hooks:
1212
- id: pdm-lock-check
1313
name: check lock file matches pyproject
14+
entry: sh -c "pdm lock -v --check || pdm lock --update-reuse"
1415
- repo: https://github.com/astral-sh/ruff-pre-commit
1516
rev: v0.11.7
1617
hooks:

0 commit comments

Comments
 (0)