Skip to content

Use adaptive logic to decide on correct alias for pre-commit system/u…#1241

Merged
nathanjmcdougall merged 3 commits intomainfrom
1149-new-aliases-for-pre-commit-language-system-config
Dec 29, 2025
Merged

Use adaptive logic to decide on correct alias for pre-commit system/u…#1241
nathanjmcdougall merged 3 commits intomainfrom
1149-new-aliases-for-pre-commit-language-system-config

Conversation

@nathanjmcdougall
Copy link
Collaborator

…nsupported language hooks

@nathanjmcdougall nathanjmcdougall linked an issue Dec 28, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 call get_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
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 28, 2025

CodSpeed Performance Report

Merging #1241 will not alter performance

Comparing 1149-new-aliases-for-pre-commit-language-system-config (c5b73d4) with main (7fa0576)

Summary

✅ 2 untouched

@nathanjmcdougall
Copy link
Collaborator Author

I think we need to do #492 first to avoid the regression

@nathanjmcdougall nathanjmcdougall marked this pull request as draft December 28, 2025 22:38
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review December 29, 2025 19:41
@nathanjmcdougall nathanjmcdougall merged commit 397d419 into main Dec 29, 2025
19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 1149-new-aliases-for-pre-commit-language-system-config branch December 29, 2025 20:10
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.

New aliases for pre-commit language: system config

2 participants