Skip to content

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

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
EvanYao826:refactor-isinstance-match-case-5
May 31, 2026
Merged

refactor: convert isinstance chains to match/case (part 5)#36503
asukaminato0721 merged 1 commit 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

@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

github-actions Bot commented May 22, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 45.84% 45.84% 0.00%
Strict coverage 45.36% 45.36% 0.00%
Typed symbols 24,720 24,720 0
Untyped symbols 29,514 29,514 0
Modules 2762 2762 0

Convert isinstance chains to Python 3.10+ match/case in trace providers:
- aliyun_trace.py
- arize_phoenix_trace.py
- langfuse_trace.py
- langsmith_trace.py
- opik_trace.py
- weave_trace.py

Changes:
- Replace if/isinstance chains with structural pattern matching
- Add wildcard case _: for exhaustive matching
- Restore logger.debug in weave_trace.py
- Preserve existing logging and try/except blocks

Refs: langgenius#35902
auto-merge was automatically disabled May 31, 2026 02:49

Head branch was pushed to by a user without write access

@EvanYao826 EvanYao826 force-pushed the refactor-isinstance-match-case-5 branch from 4e7b01e to 9373421 Compare May 31, 2026 02:49
@asukaminato0721 asukaminato0721 enabled auto-merge May 31, 2026 15:08
@asukaminato0721 asukaminato0721 added this pull request to the merge queue May 31, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 31, 2026
Merged via the queue into langgenius:main with commit df6b5be May 31, 2026
31 checks passed
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: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