-
-
Notifications
You must be signed in to change notification settings - Fork 124
Don't check Python executable path in health check #1496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1496 +/- ##
==========================================
+ Coverage 91.50% 91.51% +0.01%
==========================================
Files 87 87
Lines 18154 18149 -5
==========================================
- Hits 16611 16609 -2
+ Misses 1543 1540 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 fixes a bug where prek incorrectly identifies Python hooks as unhealthy when the Python toolchain path involves symlinks. The issue occurred because the health check compared paths without resolving symlinks, causing mismatches when the same path was accessed through different symlink hierarchies (e.g., cpython-3.12 vs cpython-3.12.12).
Changes:
- Canonicalizes Python executable paths in
query_python_infoto resolve symlinks before storing - Canonicalizes stored toolchain path in health check before comparison
- Adds integration test to verify symlinked toolchain scenario works correctly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/prek/src/languages/python/python.rs | Adds path canonicalization in query_python_info (line 78) and check_health (line 203) to resolve symlinks before path comparison |
| crates/prek/tests/languages/python.rs | Adds integration test that creates a symlinked home directory to verify health checks pass when paths involve symlinks |
📦 Cargo Bloat ComparisonBinary size change: +0.00% (22.5 MiB → 22.5 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
d4fd812 to
b8c78d4
Compare
b8c78d4 to
d4fd812
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
|
Thanks! I simplified it a bit so it just doesn’t check the Python executable path at all. I think it’s not necessary, and it lines up with how pre-commit works. |
2d995e6 to
876c6fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
876c6fa to
8d6991a
Compare
When checking the health of a Python hook installation, the stored toolchain path and the queried path may differ if symlinks are involved (e.g., when the Python executable or a parent directory is a symlink). This change canonicalizes both paths before comparison to resolve symlinks and ensure consistent path matching regardless of how the Python toolchain is accessed. - Canonicalize `python_exec` in `query_python_info` after constructing it - Canonicalize `info.toolchain` in `check_health` before comparison - Add integration test for symlinked toolchain scenario
8d6991a to
cbfb4bb
Compare
Okay, sounds good to me. I don't mind. |
It looked like
prekwas always re-installing my hooks.Investigating with
prek install-hooks -vvshowed my a bunch of warnings:/home/user/.local/share/uv/python/cpython-3.12-linux-x86_64-gnuis a symlink to
/home/user/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnuso these do actually match.
This PR fixes this by canonicalizing both paths before comparison to resolve symlinks and ensure consistent path matching regardless of how the Python toolchain is accessed.
python_execinquery_python_infoafter constructing itinfo.toolchainincheck_healthbefore comparison