fix: resolve variable shadowing in search_token function#114
Open
namedfarouk wants to merge 3 commits intoOpenGradient:mainfrom
Open
fix: resolve variable shadowing in search_token function#114namedfarouk wants to merge 3 commits intoOpenGradient:mainfrom
namedfarouk wants to merge 3 commits intoOpenGradient:mainfrom
Conversation
The 'token' parameter (str) was being overwritten by a TokenMetadata result using the same variable name. Renamed the result variable to 'result' to improve code clarity and fix the type shadowing issue.
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.
Problem
In
agent/tools.py, thesearch_tokenfunction declared a parametertoken: strbut immediately overwrote it with a completely differenttype
Optional[TokenMetadata]using the same variable name.This is variable shadowing - it's confusing, bad practice, and makes
the code harder to debug and maintain.
Fix
Renamed the result variable from
tokentoresultto clearlyseparate the input string from the returned metadata object.
Files changed
agent/tools.py-search_tokenfunction insidecreate_analytics_agent_toolkit