Use adaptive logic to decide on correct alias for pre-commit system/u…#1241
Conversation
…nsupported language hooks
There was a problem hiding this comment.
Pull request overview
This PR introduces adaptive logic to determine the correct pre-commit language alias (system vs unsupported) based on the minimum pre-commit version specified in a project's configuration. The change ensures compatibility across different pre-commit versions, as system language was replaced with unsupported in pre-commit 4.4.0.
Key changes:
- Added
get_system_language()helper function that checks the minimum pre-commit version and returns the appropriate language keyword - Updated all tools using
Language("system")to callget_system_language()instead - Added comprehensive test coverage for the version detection logic
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/usethis/_integrations/pre_commit/language.py |
New module containing get_system_language() helper function that returns appropriate language keyword based on pre-commit version |
src/usethis/_integrations/pre_commit/hooks.py |
Updated placeholder hook to use get_system_language() instead of hardcoded Language("system") |
src/usethis/_tool/impl/deptry.py |
Updated deptry pre-commit hooks to use get_system_language() for both uv and non-uv backends |
src/usethis/_tool/impl/import_linter.py |
Updated import-linter pre-commit hooks to use get_system_language() for both uv and non-uv backends |
src/usethis/_tool/impl/requirements_txt.py |
Updated requirements.txt export hook to use get_system_language() |
tests/usethis/_integrations/pre_commit/test_language.py |
New test file with comprehensive coverage of get_system_language() across various version scenarios |
tests/usethis/_tool/impl/test_deptry.py |
Added tests verifying deptry tool correctly uses adaptive language logic based on pre-commit version |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #1241 will not alter performanceComparing Summary
|
|
I think we need to do #492 first to avoid the regression |
…nsupported language hooks