chore: update template files to use modern type annotations#4477
Merged
greysonlalonde merged 1 commit intocrewAIInc:mainfrom Feb 13, 2026
Merged
Conversation
## Summary Update crew template files to use built-in types (`list`) instead of importing from `typing` module (`List`), following modern Python 3.10+ best practices. ## Changes - `lib/crewai/src/crewai/cli/templates/crew/crew.py`: - Removed `from typing import List` - Changed `List[BaseAgent]` to `list[BaseAgent]` - Changed `List[Task]` to `list[Task]` - `lib/crewai/src/crewai/cli/templates/flow/crews/poem_crew/poem_crew.py`: - Removed `from typing import List` - Changed `List[BaseAgent]` to `list[BaseAgent]` - Changed `List[Task]` to `list[Task]` ## Rationale Since the project requires Python 3.10+ (as specified in pyproject.toml: `requires-python = ">=3.10,<3.14"`), using built-in generic types (`list[T]`) instead of imported types from `typing` (`List[T]`) is: - More modern and follows PEP 585 - Simpler and cleaner code - Removes unnecessary imports - Aligns with current Python best practices ## Impact - **Low Risk**: Only affects template files used for generating new crews - Existing code is unaffected - Generated code will use modern syntax (supported in Python 3.10+) ## Testing Template files are syntax-valid Python code and will generate valid crew files when used by the CLI.
Contributor
|
@hobostay thanks! this is highly appreciated |
greysonlalonde
approved these changes
Feb 13, 2026
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
Update crew template files to use built-in types (
list) instead of importing fromtypingmodule (List), following modern Python 3.10+ best practices (PEP 585).Changes
lib/crewai/src/crewai/cli/templates/crew/crew.pyfrom typing import ListList[BaseAgent]→list[BaseAgent]List[Task]→list[Task]lib/crewai/src/crewai/cli/templates/flow/crews/poem_crew/poem_crew.pyfrom typing import ListList[BaseAgent]→list[BaseAgent]List[Task]→list[Task]Rationale
Since the project requires Python 3.10+ (
requires-python = ">=3.10,<3.14"in pyproject.toml), using built-in generic types (list[T]) instead of imported types fromtyping(List[T]) is:✅ More modern - Follows PEP 585 (Python 3.9+)
✅ Cleaner code - Removes unnecessary imports
✅ Future-proof - Aligns with current Python best practices
✅ Consistent - Many Python projects have already adopted this style
Impact
Example
Before:
After:
🤖 Generated with Claude Code
Note
Low Risk
Only adjusts type annotations in scaffolding templates (no functional logic changes); risk is limited to Python-version compatibility, which is already 3.10+.
Overview
Updates the CLI crew templates to use PEP 585 built-in generics by removing
typing.Listimports and changingagents/tasksannotations fromList[...]tolist[...]increw.pyandpoem_crew.py.This is a template-only modernization for newly generated projects and does not change runtime behavior.
Written by Cursor Bugbot for commit 2291909. This will update automatically on new commits. Configure here.