Skip to content

fix(beartype): remove package-wide import hooks - #19531

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
6ba3i:fix/remove-package-beartype-hooks
Sep 14, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
6ba3i:fix/remove-package-beartype-hooks

Conversation

@6ba3i

@6ba3i 6ba3i commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Removed unnecessary beartype hooks from three package imports. This prevents unwanted import-time instrumentation and dependency coupling.
based on #15258

@6ba3i
6ba3i requested a review from wangq8 September 11, 2026 07:41
@6ba3i 6ba3i added the ci Continue Integration label Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 25818573-0f3e-402f-839b-3bd8a74087f9

📥 Commits

Reviewing files that changed from the base of the PR and between ebd2b8e and 7e076e4.

⛔ Files ignored due to path filters (2)
  • sdk/python/uv.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • deepdoc/__init__.py
  • pyproject.toml
  • sdk/python/ragflow_sdk/__init__.py
  • tools/chatgpt-on-wechat/plugins/__init__.py

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The changes make beartype optional during package initialization in three packages. Runtime checking remains active when available. The minimum ollama version changes from 0.5.0 to 0.5.1.

Changes

Package runtime and dependency updates

Layer / File(s) Summary
Guard optional beartype initialization
deepdoc/__init__.py, sdk/python/ragflow_sdk/__init__.py, tools/chatgpt-on-wechat/plugins/__init__.py
Each initializer catches ImportError when beartype is unavailable. Runtime type checking remains enabled when the package is installed.
Raise ollama minimum version
pyproject.toml
The minimum ollama version changes from 0.5.0 to 0.5.1.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: wangq8

Merge Risk: ⚪ Minimal · up to 7e076

The optional dependency handling and Ollama version update have no supported unresolved merge risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required Summary section and clearly states that the PR removes unnecessary beartype hooks to prevent import-time instrumentation and dependency coupling.
Title check ✅ Passed The title is concise and accurately identifies the main change: removing package-wide beartype import hooks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

A rabbit checks the package gate
If beartype hops in, types validate
If absent, imports still proceed
Ollama gets the version it needs
Three starters now handle the load

Comment @coderabbitai help to get the list of available commands.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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:

  1. 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 have beartype installed lose type checking for deepdoc, 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).

  2. Dead dependency. sdk/python/pyproject.toml still declares beartype>=0.20.0,<1.0.0 as a runtime dependency of the SDK. After this change nothing in ragflow_sdk uses it. Either drop the dependency or keep the hook; shipping an installed-but-unused runtime dep is inconsistent.

  3. 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.

  4. Tests. test/unit_test/deepdoc/parser/test_somark_parser.py and test_mistral_parser.py deliberately bypass deepdoc/__init__.py to avoid beartype_this_package(); after this change those workarounds are unnecessary, and test_mistral_parser.py even relies on "beartype runs in production" semantics for one annotation. No tests are added/updated. Please add at least a check that import deepdoc and import ragflow_sdk succeed in an environment without beartype (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

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 37.35%. Comparing base (e3bb9e1) to head (7e076e4).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
sdk/python/ragflow_sdk/__init__.py 75.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8
wangq8 merged commit 9ee43ae into infiniflow:main Sep 14, 2026
8 checks passed
@6ba3i
6ba3i deleted the fix/remove-package-beartype-hooks branch September 22, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants