refactor: convert isinstance chains to match/case (part 3)#36242
Merged
asukaminato0721 merged 2 commits intoMay 16, 2026
Merged
Conversation
Convert multi-branch isinstance/if-elif chains to structural pattern matching (match/case) for better readability and exhaustiveness checking. Files converted: - api/providers/trace/trace-mlflow/mlflow_trace.py (trace dispatch + _parse_prompts) - api/providers/trace/trace-tencent/tencent_trace.py (trace dispatch) - api/core/tools/mcp_tool/tool.py (content type dispatch) - api/core/app/apps/advanced_chat/generate_task_pipeline.py (stream response dispatch) - api/core/app/apps/workflow/generate_task_pipeline.py (stream response dispatch) - api/core/base/tts/app_generator_tts_publisher.py (message content dispatch) - api/core/app/apps/workflow_app_runner.py (graph event dispatch) - api/enterprise/telemetry/enterprise_trace.py (trace dispatch) Fixes langgenius#35902
Contributor
Pyrefly Type Coverage
|
Contributor
|
@dosu how is this pr |
|
This PR looks good. Here's a quick assessment: ✅ No issues detected. The conversion is safe and well-executed:
The refactoring improves readability and makes unhandled types explicit via To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
asukaminato0721
approved these changes
May 16, 2026
zhangtaodemama
added a commit
to zhangtaodemama/langgenius-dify-bfaadcb0c706
that referenced
this pull request
May 16, 2026
This was referenced May 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#35902
Convert multi-branch isinstance/if-elif chains to structural pattern matching (match/case) for better readability and exhaustiveness checking.
Changes
8 files converted:
trace-mlflow/mlflow_trace.py— trace dispatch (7 branches) +_parse_prompts(3 branches)trace-tencent/tencent_trace.py— trace dispatch (7 branches)core/tools/mcp_tool/tool.py— MCP content type dispatch with nested match (4 branches)advanced_chat/generate_task_pipeline.py— stream response dispatch (4 branches)workflow/generate_task_pipeline.py— stream response dispatch (4 branches)core/base/tts/app_generator_tts_publisher.py— message content type dispatchworkflow_app_runner.py— graph event dispatch (10 branches)enterprise/enterprise_trace.py— trace dispatch (10 branches)Benefits
case _: passmakes it explicit when a type is unhandled