fix: Use typing_extensions for Self in Python < 3.11

Adds typing_extensions as a dependency and uses a conditional
import for the Self type in src/crewai/memory/memory.py to
ensure compatibility with Python 3.10, resolving the
ImportError seen in CI.

Refs #2575

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-04-10 16:29:45 +00:00
parent be8d3765a0
commit 129c004efb
2 changed files with 8 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ dependencies = [
"blinker>=1.9.0",
"json5>=0.10.0",
]
"typing-extensions>=4.7.0", # For Self type backport
[project.urls]
Homepage = "https://crewai.com"

View File

@@ -1,4 +1,10 @@
from typing import Any, Dict, List, Optional, Self
import sys
from typing import Any, Dict, List, Optional
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self
from pydantic import BaseModel