fix: remove mutable default arguments in SemanticRouter (follow-up to #700) - #737
Open
harshadkhetpal wants to merge 1 commit into
Open
harshadkhetpal wants to merge 1 commit into
harshadkhetpal wants to merge 1 commit into
Conversation
…edis#700) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Harshad Khetpal <harshadkhetpal@users.noreply.github.com>
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
Follow-up to #700 (merged last month):
extensions/router/semantic.pyhas the same shared-mutable-default pattern (ruff B006) in code that wasn't covered there:SemanticRouter.__init__(connection_kwargs: dict[str, Any] = {})get_route_references(reference_ids: list[str] = [], keys: list[str] = [])delete_route_references(reference_ids: list[str] = [], keys: list[str] = [])All five become
| None = None. Unlike #700, no normalization statements are needed — I audited every use:__init__already forwardsconnection_kwargs or None, and both methods only touchreference_ids/keysbehind truthiness guards (if reference_ids:,if not keys:with reassignment before any iteration). SoNonebehaves identically to the old shared{}/[]at every site, and the diff is just the five signature lines.Testing
python -m py_compilepasses;ruff check --select B006on the file goes from 5 errors to clean.🤖 Generated with Claude Code
Note
Low Risk
Signature-only fix for shared mutable defaults; call sites already handle
Nonelike empty dict/list.Overview
Follow-up to #700: fixes ruff B006 mutable default arguments on
SemanticRouterinsemantic.py.__init__now takesconnection_kwargsasdict[str, Any] | None = Noneinstead of= {}.get_route_referencesanddelete_route_referencesusereference_idsandkeysaslist[str] | None = Noneinstead of= [].No new
if x is None: x = ...normalization—the existingconnection_kwargs or Noneforward and truthiness checks onreference_ids/keysalready treat omitted args the same as empty collections.Reviewed by Cursor Bugbot for commit 37a104e. Bugbot is set up for automated code reviews on this repo. Configure here.