python: use TypedDict from typing_extensions on python 3.9 and 3.10

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel 2024-03-25 17:30:56 -04:00 committed by Aaron Miller
parent adea3811ea
commit 446668674e
2 changed files with 8 additions and 1 deletions

View File

@ -9,13 +9,19 @@ import sys
import threading
from enum import Enum
from queue import Queue
from typing import Any, Callable, Generic, Iterable, TypedDict, TypeVar, overload
from typing import Any, Callable, Generic, Iterable, TypeVar, overload
if sys.version_info >= (3, 9):
import importlib.resources as importlib_resources
else:
import importlib_resources
if (3, 9) <= sys.version_info < (3, 11):
# python 3.9 broke generic TypedDict, python 3.11 fixed it
from typing_extensions import TypedDict
else:
from typing import TypedDict
EmbeddingsType = TypeVar('EmbeddingsType', bound='list[Any]')

View File

@ -90,6 +90,7 @@ setup(
'requests',
'tqdm',
'importlib_resources; python_version < "3.9"',
'typing-extensions>=4.3.0; python_version >= "3.9" and python_version < "3.11"',
],
extras_require={
'dev': [