š [Bug] PydanticUserError ā Should use typing_extensions.TypedDict on Python 3.10+
š Description
When running graphiti_mcp_server.py (or any module in this monorepo) in a Python 3.10 environment, I encountered a PydanticUserError related to TypedDict imports.
PydanticUserError: Please use typing_extensions.TypedDict instead of typing.TypedDict on Python < 3.12.
This happens because Pydantic 2.x requires TypedDict implementations that provide richer metadata for schema generation, which is only fully supported in the typing module for Python >= 3.12. For earlier Python versions, typing_extensions.TypedDict must be used.
š Environment
- Python Version: 3.10.x
- Pydantic Version: 2.x
- Operating System: macOS
ā Expected Behavior
- All
TypedDictusage should consistently import fromtyping_extensionsfor Python < 3.12 - No runtime errors when generating Pydantic models or OpenAPI schemas
- Cross-version compatibility should work seamlessly
ā Actual Behavior
- Multiple locations in the codebase use incompatible imports:
from typing import TypedDict
Pydantic fails during schema generation with the above error Server cannot start properly in Python 3.10/3.11 environments
š Steps to Reproduce
- Set up Python 3.10 environment
- Install dependencies including Pydantic 2.x
- Run graphiti_mcp_server.py
- Observe the PydanticUserError
Example traceback:
pydantic.errors.PydanticUserError: Please use typing_extensions.TypedDict instead of typing.TypedDict on Python < 3.12.
Find all problematic imports:
bashgrep -rn "from typing import.*TypedDict" .
š” Proposed Solution
- Global Import Replacement:
# Replace this
from typing import TypedDict
# With this
from typing_extensions import TypedDict
-
Dependency Management: Ensure
typing_extensionsis explicitly listed in requirements Add version constraints if needed -
Prevention: Add a pre-commit hook or linting rule to catch future typing.TypedDict usage Consider adding a comment in code style guidelines
š§ Additional Context
The typing_extensions package is already a standard dependency for multi-version Python support and provides the necessary TypedDict implementation that Pydantic expects.
š Acceptance Criteria
- [ ] All typing.TypedDict imports replaced with typing_extensions.TypedDict
- [ ] Server runs successfully on Python 3.10+
- [ ] No Pydantic schema generation errors
- [ ] typing_extensions added to requirements if missing
- [ ] Optional: Prevention mechanism added to avoid regression
⨠Benefit
Ensures full compatibility for all supported Python versions as declared.
Thanks for your awesome work! Iām happy to open a PR if you prefer!
@MumuTW Is this still an issue? Please confirm within 14 days or this issue will be closed.
@MumuTW Is this still an issue? Please confirm within 14 days or this issue will be closed.