fix: handle TypeGuard import for compatibility with older Python versions

This commit is contained in:
Mason Daugherty 2025-08-04 13:06:42 -04:00
parent a3929c71e4
commit 719c9dfaaa
No known key found for this signature in database

View File

@ -103,9 +103,14 @@ The module defines several types of content blocks, including:
""" # noqa: E501
import warnings
from typing import Any, Literal, Optional, TypeGuard, Union
from typing import Any, Literal, Optional, Union
from uuid import uuid4
try:
from typing import TypeGuard
except ImportError:
from typing_extensions import TypeGuard
from typing_extensions import NotRequired, TypedDict, get_args, get_origin