Skip to content

refactor: add missing @override decorator to PluginModelRuntime - #36493

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
AlsoTheZv3n:refactor/add-override-plugin-model-runtime
May 21, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
AlsoTheZv3n:refactor/add-override-plugin-model-runtime

Conversation

@AlsoTheZv3n

Copy link
Copy Markdown
Contributor

Relates to #36406.

Adds @override (PEP 698, from typing import override) to all 17 ModelRuntime protocol methods implemented in PluginModelRuntime (api/core/plugin/impl/model_runtime.py):

  • fetch_model_providers
  • get_provider_icon
  • validate_provider_credentials
  • validate_model_credentials
  • get_model_schema
  • invoke_llm
  • invoke_llm_with_structured_output
  • get_llm_num_tokens
  • invoke_text_embedding
  • invoke_multimodal_embedding
  • get_text_embedding_num_tokens
  • invoke_rerank
  • invoke_multimodal_rerank
  • invoke_tts
  • get_tts_model_voices
  • invoke_speech_to_text
  • invoke_moderation

@override is placed on the implementation methods only — not on the @overload-decorated stubs of invoke_llm and invoke_llm_with_structured_output (pyrefly's missing-override-decorator check targets the implementation, matching the errors listed in the issue body).

Pattern follows the merged example in #36425 and previous slices #36486, #36490, #36491, #36492.

Relates to langgenius#36406. Adds @OverRide (17 decorators) to all ModelRuntime
protocol methods implemented in PluginModelRuntime: fetch_model_providers,
get_provider_icon, validate_provider_credentials, validate_model_credentials,
get_model_schema, invoke_llm, invoke_llm_with_structured_output,
get_llm_num_tokens, invoke_text_embedding, invoke_multimodal_embedding,
get_text_embedding_num_tokens, invoke_rerank, invoke_multimodal_rerank,
invoke_tts, get_tts_model_voices, invoke_speech_to_text, invoke_moderation.

@OverRide is placed on the implementation methods only, not on the
@overload-decorated stubs of invoke_llm and invoke_llm_with_structured_output
(pyrefly's missing-override-decorator check targets the implementation).

Uses 'from typing import override' (Python 3.12+ stdlib) per the pattern
established in langgenius#36486.
@AlsoTheZv3n
AlsoTheZv3n requested a review from WH-2099 as a code owner May 21, 2026 16:39
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 44.64% 44.64% 0.00%
Strict coverage 44.16% 44.16% 0.00%
Typed symbols 22,971 22,971 0
Untyped symbols 28,793 28,793 0
Modules 2611 2611 0

@asukaminato0721
asukaminato0721 added this pull request to the merge queue May 21, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 21, 2026
Merged via the queue into langgenius:main with commit 82b0a03 May 21, 2026
27 checks passed
Ssazurov pushed a commit to Ssazurov/dify that referenced this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants