dify icon indicating copy to clipboard operation
dify copied to clipboard

refactor: add missing @override decorators to method overrides

Open EvanYao826 opened this issue 6 months ago • 2 comments

Summary

Added @override decorator to methods that override parent class methods but were missing the decorator, as flagged by pyright's missing-override-decorator check.

#36406

Changes

  • Added from typing import override import to affected files
  • Added @override decorator to 53 method overrides across the codebase
  • Covers: get_field_value, settings_customise_sources, _organize_prompt_messages, generate_response, and other overridden methods

Checklist

  • [x] Title explains the problem clearly (e.g., refactor: add missing @override decorators)
  • [x] Tests added/updated (if applicable)
  • [x] Documentation updated (if applicable)
  • [x] No breaking changes

EvanYao826 avatar May 27 '26 02:05 EvanYao826

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-06-03 06:56:35.590978428 +0000
+++ /tmp/pyrefly_pr.txt	2026-06-03 06:56:23.187903671 +0000
@@ -40,6 +40,14 @@
    --> core/llm_generator/llm_generator.py:653:60
 ERROR Class member `OpsTraceProviderConfigMap.__getitem__` overrides parent class `UserDict` in an inconsistent manner [bad-override-param-name]
    --> core/ops/ops_trace_manager.py:218:9
+ERROR `@override` should only be applied to the implementation of an overloaded function. [invalid-overload]
+   --> core/plugin/impl/model_runtime.py:276:9
+ERROR `@override` should only be applied to the implementation of an overloaded function. [invalid-overload]
+   --> core/plugin/impl/model_runtime.py:291:9
+ERROR `@override` should only be applied to the implementation of an overloaded function. [invalid-overload]
+   --> core/plugin/impl/model_runtime.py:342:9
+ERROR `@override` should only be applied to the implementation of an overloaded function. [invalid-overload]
+   --> core/plugin/impl/model_runtime.py:357:9
 ERROR `list[dict[str, str | dict[str, str]]] | list[Unknown]` is not assignable to TypedDict key `tool_calls` with type `list[dict[str, str]] | str` [bad-typed-dict-key]
   --> core/prompt/utils/prompt_message_util.py:83:44
 ERROR Argument `Unknown | None` is not assignable to parameter `result_object` with type `dict[str, Any]` in function `WaterCrawlProvider._structure_data` [bad-argument-type]

github-actions[bot] avatar May 27 '26 04:05 github-actions[bot]

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 46.13% 46.13% 0.00%
Strict coverage 45.62% 45.62% 0.00%
Typed symbols 25,062 25,062 0
Untyped symbols 29,596 29,596 0
Modules 2790 2790 0

github-actions[bot] avatar May 27 '26 04:05 github-actions[bot]

@asukaminato0721 CI is now all green — could you take another look? The earlier CI failures have been resolved. Thanks!

EvanYao826 avatar May 31 '26 02:05 EvanYao826

@asukaminato0721 CI has been fixed — all 31 checks are passing now (including the "Style Check / Python Style" that was failing). The @override decorator placement was corrected in a follow-up commit. Could you take another look? Thanks!

EvanYao826 avatar Jun 09 '26 08:06 EvanYao826

Updated — CI failures resolved in the latest commit. Ready for re-review when convenient.

EvanYao826 avatar Jun 11 '26 02:06 EvanYao826

Thanks for the contribution! This work has already been included via #36501, and after rebasing this branch there is no remaining diff against main. I’m closing this PR to keep the queue tidy.

WH-2099 avatar Jun 18 '26 00:06 WH-2099