Repository navigation
fix(beartype): remove package-wide import hooks - #19531
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe changes make ChangesPackage runtime and dependency updates
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The optional dependency handling and Ollama version update have no supported unresolved merge risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. A rabbit checks the package gate Comment |
wangq8
left a comment
There was a problem hiding this comment.
Reviewed the diff. It is mechanically small (pure deletions in three __init__.py files) and I agree with the underlying concern: installing beartype's import hooks at package-import time is heavy and hard-fails when beartype is absent (issue #14931). A few points before this lands:
-
Scope differs from the referenced fix. #15258 (now closed/unmerged) addressed the same issue by guarding the import with
try/except ImportError, which preserves runtime type checking on healthy installs while tolerating a missing one. This PR removes the hooks outright, so even environments that do havebeartypeinstalled lose type checking fordeepdoc,ragflow_sdk, and the chatgpt-on-wechat plugin. Please confirm that full removal — rather than tolerating a missing install — is the intended behaviour change, and update the description accordingly (it currently only says "based on #15258", which did something different). -
Dead dependency.
sdk/python/pyproject.tomlstill declaresbeartype>=0.20.0,<1.0.0as a runtime dependency of the SDK. After this change nothing inragflow_sdkuses it. Either drop the dependency or keep the hook; shipping an installed-but-unused runtime dep is inconsistent. -
Historical intent. This reverses "Add back beartype (#3967)", which itself undid "Removed beartype (#3528)". Worth confirming with maintainers which direction is desired, since the repo has flip-flopped here.
-
Tests.
test/unit_test/deepdoc/parser/test_somark_parser.pyandtest_mistral_parser.pydeliberately bypassdeepdoc/__init__.pyto avoidbeartype_this_package(); after this change those workarounds are unnecessary, andtest_mistral_parser.pyeven relies on "beartype runs in production" semantics for one annotation. No tests are added/updated. Please add at least a check thatimport deepdocandimport ragflow_sdksucceed in an environment withoutbeartype(the exact scenario from #14931).
If full removal is genuinely the goal, I'd prefer centralizing that decision (e.g. one guarded import site) over deleting instrumentation from three packages ad hoc. Posting as comment, not a block.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19531 +/- ##
=======================================
Coverage 37.35% 37.35%
=======================================
Files 54 54
Lines 15384 15386 +2
Branches 125 125
=======================================
+ Hits 5746 5747 +1
- Misses 9611 9612 +1
Partials 27 27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Removed unnecessary beartype hooks from three package imports. This prevents unwanted import-time instrumentation and dependency coupling.
based on #15258