Skip to content

chore: update template files to use modern type annotations#4477

Merged
greysonlalonde merged 1 commit intocrewAIInc:mainfrom
hobostay:chore/update-templates-modern-types
Feb 13, 2026
Merged

chore: update template files to use modern type annotations#4477
greysonlalonde merged 1 commit intocrewAIInc:mainfrom
hobostay:chore/update-templates-modern-types

Conversation

@hobostay
Copy link
Contributor

@hobostay hobostay commented Feb 13, 2026

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 (PEP 585).

Changes

lib/crewai/src/crewai/cli/templates/crew/crew.py

  • Removed from typing import List
  • Changed List[BaseAgent]list[BaseAgent]
  • Changed List[Task]list[Task]

lib/crewai/src/crewai/cli/templates/flow/crews/poem_crew/poem_crew.py

  • Removed from typing import List
  • Changed List[BaseAgent]list[BaseAgent]
  • Changed 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 from typing (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

  • Scope: Only affects template files used for generating new crews
  • Risk: Low - Existing code is unaffected; only newly generated crews will use the modern syntax
  • Compatibility: All syntax is valid in Python 3.10+

Example

Before:

from typing import List

agents: List[BaseAgent]
tasks: List[Task]

After:

agents: list[BaseAgent]
tasks: list[Task]

🤖 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.List imports and changing agents/tasks annotations from List[...] to list[...] in crew.py and poem_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.

## 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.
@greysonlalonde
Copy link
Contributor

@hobostay thanks! this is highly appreciated

@greysonlalonde greysonlalonde merged commit 670cdca into crewAIInc:main Feb 13, 2026
39 checks passed
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.

2 participants