From 446668674eaf4a800982beeedab03645288d2bd4 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 25 Mar 2024 17:30:56 -0400 Subject: [PATCH] python: use TypedDict from typing_extensions on python 3.9 and 3.10 Signed-off-by: Jared Van Bortel --- gpt4all-bindings/python/gpt4all/_pyllmodel.py | 8 +++++++- gpt4all-bindings/python/setup.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gpt4all-bindings/python/gpt4all/_pyllmodel.py b/gpt4all-bindings/python/gpt4all/_pyllmodel.py index ded4ea5e..e8c6266d 100644 --- a/gpt4all-bindings/python/gpt4all/_pyllmodel.py +++ b/gpt4all-bindings/python/gpt4all/_pyllmodel.py @@ -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]') diff --git a/gpt4all-bindings/python/setup.py b/gpt4all-bindings/python/setup.py index 5d138934..b5345b08 100644 --- a/gpt4all-bindings/python/setup.py +++ b/gpt4all-bindings/python/setup.py @@ -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': [