Skip to content

Commit b776690

Browse files
ncoghlanbaonudesifeizhai
authored andcommitted
No generic typed dicts in Python 3.10
1 parent 296e78e commit b776690

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/lmstudio/json_api.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import copy
1414
import inspect
1515
import json
16+
import sys
1617
import uuid
1718
import warnings
1819

@@ -1091,9 +1092,17 @@ def __init__(
10911092
super().__init__(model_key, params, on_load_progress)
10921093

10931094

1094-
class ToolParamDefDict(TypedDict, Generic[T]):
1095-
type: type[T]
1096-
default: NotRequired[T]
1095+
if sys.version_info < (3, 11):
1096+
# Generic typed dictionaries aren't supported in Python 3.10
1097+
# https://github.com/python/cpython/issues/89026
1098+
class ToolParamDefDict(TypedDict):
1099+
type: type[Any]
1100+
default: NotRequired[Any]
1101+
else:
1102+
1103+
class ToolParamDefDict(TypedDict, Generic[T]):
1104+
type: type[T]
1105+
default: NotRequired[T]
10971106

10981107

10991108
class ToolFunctionDefDict(TypedDict):

0 commit comments

Comments
 (0)