Skip to content

fix: rename loop variable that shadows provider parameter in create_crew()#5401

Closed
Dheeraj-Bhaskaruni wants to merge 2 commits intocrewAIInc:mainfrom
Dheeraj-Bhaskaruni:fix/create-crew-variable-shadowing
Closed

fix: rename loop variable that shadows provider parameter in create_crew()#5401
Dheeraj-Bhaskaruni wants to merge 2 commits intocrewAIInc:mainfrom
Dheeraj-Bhaskaruni:fix/create-crew-variable-shadowing

Conversation

@Dheeraj-Bhaskaruni
Copy link
Copy Markdown

@Dheeraj-Bhaskaruni Dheeraj-Bhaskaruni commented Apr 10, 2026

Summary

Fixes #5270

The for provider, env_keys in ENV_VARS.items() loop in create_crew() shadows the provider function parameter. After the loop completes, provider holds the last key from ENV_VARS instead of the caller's original value.

Renamed the loop variable to env_provider to prevent the shadowing.

File changed

  • lib/crewai/src/crewai/cli/create_crew.py

Test plan

  • crewai create crew test --provider openai still works correctly
  • Existing env var detection still identifies configured providers
  • No linter warnings for variable shadowing (pylint W0621)

…_crew()

The `for provider, env_keys in ENV_VARS.items()` loop on line 214
shadows the `provider` function parameter. After the loop, `provider`
no longer holds the caller's original value. Renamed the loop variable
to `env_provider` to prevent this.

Fixes crewAIInc#5270
@greysonlalonde
Copy link
Copy Markdown
Contributor

Duplicate of #5272. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] create_crew() loop variable shadows provider function parameter

2 participants