refactor: convert isinstance chains to match/case (part 5)#36503
Open
EvanYao826 wants to merge 2 commits into
Open
refactor: convert isinstance chains to match/case (part 5)#36503EvanYao826 wants to merge 2 commits into
EvanYao826 wants to merge 2 commits into
Conversation
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
Contributor
Pyrefly Type Coverage
|
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.
Refs #35902
Continuing the isinstance → match/case refactoring series.
Changes
core/workflow/node_runtime.py
_map_tool_message: 8 isinstance checks → match/case forToolInvokeMessagesubtypes_map_invocation_exception: 4 isinstance checks → match/case for exception typesenterprise/telemetry/enterprise_trace.py
trace(): 10-way isinstance dispatch → match/case forBaseTraceInfosubtypesTrace providers (8 files)
trace(): 7-way isinstance dispatch → match/case in all trace providers: