Skip to content

Commit cb9ff9a

Browse files
committed
chore: Update typing imports and add NotRequired fallback
1 parent 4ea265f commit cb9ff9a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

function_schema/types.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from typing import (TypedDict, Literal, TypeVar, Union, NotRequired, Generic)
1+
from typing import TypedDict, Literal, TypeVar, Union, Generic, Optional
2+
3+
try:
4+
from typing import NotRequired
5+
except ImportError:
6+
NotRequired = TypeVar("NotRequired", bound=Optional)
27

38

49
class ParamSchema(TypedDict):
@@ -10,6 +15,7 @@ class ParamSchema(TypedDict):
1015
enum (Optional[list[str]]): The list of allowed values for the parameter (optional).
1116
default (Optional[str]): The default value for the parameter (optional).
1217
"""
18+
1319
type: str
1420
description: str
1521
enum: NotRequired[list[str]]
@@ -23,11 +29,12 @@ class RootProperty(TypedDict):
2329
type (str): Root property can only be "object".
2430
properties (dict[str, ParamSchema]): The properties of the object.
2531
"""
32+
2633
type: Literal["object"]
2734
properties: dict[str, ParamSchema]
2835

2936

30-
T = TypeVar('T', bound=Union['WithParameters', 'WithInputSchema'])
37+
T = TypeVar("T", bound=Union["WithParameters", "WithInputSchema"])
3138

3239

3340
class WithParameters(TypedDict):
@@ -52,6 +59,7 @@ class FunctionSchema(FunctionSchemaBase, Generic[T]):
5259
parameters (RootProperty): The schema for the function parameters.
5360
input_schema (ParamSchema): The schema for the function parameters if format is "claude".
5461
"""
62+
5563
pass
5664

5765

0 commit comments

Comments
 (0)