fix: handle PackageNotFoundError when commit-check is not installed - #483
Conversation
Wrap __version__ in try/except so that importing commit-check does not crash in development environments where the package has not been pip installed (e.g. running directly via uv or python -m). Falls back to '0.0.0.dev'.
✅ Deploy Preview for commit-check ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe package version lookup now catches missing distribution metadata and falls back to ChangesPackage version initialization
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #483 +/- ##
==========================================
- Coverage 97.45% 97.29% -0.17%
==========================================
Files 12 12
Lines 1179 1182 +3
==========================================
+ Hits 1149 1150 +1
- Misses 30 32 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|



Summary
When importing
commit_checkin a development environment where the package hasn't beenpip install-ed (e.g., running directly withuvorpython -m),importlib.metadata.version("commit-check")raisesPackageNotFoundError, causing the entire import to crash.Changes
PackageNotFoundErroralongsideversionfromimportlib.metadata__version__assignment in atry/except PackageNotFoundError"0.0.0.dev"when the package is not installedTests
Added
tests/version_test.pywith two test cases:__version__is a non-empty string under normal conditionsimportlib.metadata.versionto raisePackageNotFoundError, then reloads the module and asserts__version__ == "0.0.0.dev"Verification
import commit_checkno longer crashes in an uninstalled (development) environment__version__resolves correctly when the package is installed