fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5272
Open
MilesQLi wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5272MilesQLi wants to merge 1 commit intocrewAIInc:mainfrom
MilesQLi wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
In create_crew(), the for loop `for provider, env_keys in ENV_VARS.items()` reused the name `provider`, clobbering the function parameter after the loop. While the parameter is not currently referenced post-loop, the shadowing is a latent bug that would silently break any future use of the original value. Renamed to `env_provider` to keep the parameter intact.
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
Fixes #5270
In
create_crew(), the for-loopfor provider, env_keys in ENV_VARS.items()was reusing the nameprovider, which shadows the function parameter passed from the CLI's--providerflag. Renamed the loop variable toenv_providerso the original parameter value is preserved.The parameter isn't currently read after the loop (the function uses
selected_providerfrom interactive selection), so this is a latent bug rather than a visible one today. But shadowing function parameters with loop variables is a classic Python gotcha that makes the code fragile and would trip up anyone trying to useproviderlater in the function.Changes
provider→env_providerin the for-loop on line 214 and the assignment on line 219Test plan
test_create_crew.pypass