Skip to content

refactor: add missing return type hints to FeatureService methods - #46711

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
Cmz9111:fix/feature-service-type-hints
Nov 20, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
Cmz9111:fix/feature-service-type-hints

Conversation

@Cmz9111

@Cmz9111 Cmz9111 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Problem

Several methods in api/services/feature_service.py were missing return type hints, reducing type safety and code clarity:

  • get_knowledge_rate_limit(cls, tenant_id: str) — no return type
  • _fulfill_params_from_env(cls, features) — no return type
  • _fulfill_params_from_workspace_info(cls, features, tenant_id) — no return type
  • _fulfill_params_from_billing_api(cls, features, tenant_id, ...) — no return type
  • _fulfill_vector_space_from_billing_info(cls, vector_space, billing_info) — no return type

Solution

Added return type hints to all five methods:

# get_knowledge_rate_limit returns a KnowledgeRateLimitModel
def get_knowledge_rate_limit(cls, tenant_id: str) -> feature_entities.KnowledgeRateLimitModel:

# The _fulfill_* methods mutate the features object in-place and return None
def _fulfill_params_from_env(...) -> None:
def _fulfill_params_from_workspace_info(...) -> None:
def _fulfill_params_from_billing_api(...) -> None:
def _fulfill_vector_space_from_billing_info(...) -> None:

Testing

  • Verified all changes are purely type annotation additions with no behavioral changes
  • Confirmed feature_entities.KnowledgeRateLimitModel is the correct return type by inspecting the method body
  • The _fulfill_* methods are void (mutate in-place, no return statement) so -> None is correct
  • feature_entities is already imported at the top of the file

@Cmz9111
Cmz9111 requested a review from GareArc as a code owner November 18, 2026 17:29
@github-actions github-actions Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 18, 2026
@asukaminato0721 asukaminato0721 self-assigned this Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 86.86% 86.86% +0.00%
Strict coverage 86.52% 86.52% +0.00%
Typed symbols 95,422 95,420 -2
Untyped symbols 14,488 14,487 -1
Modules 4631 4631 0

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (dd990c3) to head (36cb420).
⚠️ Report is 502 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46711      +/-   ##
==========================================
+ Coverage   89.88%   90.12%   +0.23%     
==========================================
  Files        6247     6365     +118     
  Lines      391170   403226   +12056     
  Branches    78443    79957    +1514     
==========================================
+ Hits       351619   363422   +11803     
+ Misses      33446    33403      -43     
- Partials     6105     6401     +296     
Flag Coverage Δ
api 90.08% <100.00%> (+0.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 20, 2026
Merged via the queue into langgenius:main with commit d5d5b77 Nov 20, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files. waiting-for-reviewer dify-codereview: checked, nothing left for the author; a reviewer's turn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants