Skip to content

refactor: convert isinstance chains to match/case (part 5)#36503

Open
EvanYao826 wants to merge 2 commits into
langgenius:mainfrom
EvanYao826:refactor-isinstance-match-case-5
Open

refactor: convert isinstance chains to match/case (part 5)#36503
EvanYao826 wants to merge 2 commits into
langgenius:mainfrom
EvanYao826:refactor-isinstance-match-case-5

Conversation

@EvanYao826
Copy link
Copy Markdown
Contributor

Refs #35902

Continuing the isinstance → match/case refactoring series.

Changes

core/workflow/node_runtime.py

  • _map_tool_message: 8 isinstance checks → match/case for ToolInvokeMessage subtypes
  • _map_invocation_exception: 4 isinstance checks → match/case for exception types

enterprise/telemetry/enterprise_trace.py

  • trace(): 10-way isinstance dispatch → match/case for BaseTraceInfo subtypes

Trace providers (8 files)

  • trace(): 7-way isinstance dispatch → match/case in all trace providers:
    • trace-aliyun
    • trace-arize-phoenix
    • trace-langfuse
    • trace-langsmith
    • trace-mlflow
    • trace-opik
    • trace-tencent
    • trace-weave

Converted isinstance if/elif chains to structural pattern matching
(match/case) in the following files:

- core/workflow/node_runtime.py: _map_tool_message (8 cases) and
  _map_invocation_exception (4 cases)
- enterprise/telemetry/enterprise_trace.py: trace dispatch (10 cases)
- All trace providers (aliyun, arize-phoenix, langfuse, langsmith,
  mlflow, opik, tencent, weave): trace dispatch (7 cases each)

Refs langgenius#35902
@EvanYao826 EvanYao826 requested a review from QuantumGhost as a code owner May 22, 2026 03:14
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels May 22, 2026
@asukaminato0721 asukaminato0721 enabled auto-merge May 22, 2026 03:16
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 44.90% 44.90% 0.00%
Strict coverage 44.42% 44.42% 0.00%
Typed symbols 23,110 23,110 0
Untyped symbols 28,667 28,667 0
Modules 2611 2611 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants