Skip to content

Conversation

sjmonson
Copy link
Collaborator

Summary

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

  • Update pylock pre-commit hook to attempt to update the pylock file when pdm lock --check fails.

Test Plan

  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
  3. Run pdm run pre-commit run pdm-lock-check --all-files and validate that the check passes

  • "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 ##)

@jaredoconnell
Copy link
Collaborator

Could this ever trigger a lock change when dependencies do not change?

@sjmonson
Copy link
Collaborator Author

sjmonson commented Sep 3, 2025

Could this ever trigger a lock change when dependencies do not change?

No, pdm lock --check will only fail and trigger a lock update when the locked packages don't match pyproject.toml. Additionally the lock is done with --update-reuse which will avoid updating packages unless they absolutely have to.

@sjmonson sjmonson merged commit d0aca38 into main Sep 4, 2025
17 checks passed
@sjmonson sjmonson deleted the fix/pylock_pre-commit branch September 4, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants