syllable-sdk 0.44.4__py3-none-any.whl → 0.44.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- syllable_sdk/_version.py +4 -4
- syllable_sdk/directory.py +96 -34
- syllable_sdk/models/__init__.py +62 -19
- syllable_sdk/models/agentcreate.py +7 -5
- syllable_sdk/models/agentresponse.py +7 -5
- syllable_sdk/models/agentsttprovider.py +1 -0
- syllable_sdk/models/agentupdate.py +7 -5
- syllable_sdk/models/bridgephrasesconfig.py +0 -9
- syllable_sdk/models/custommessagecreaterequest.py +7 -2
- syllable_sdk/models/custommessageresponse.py +7 -2
- syllable_sdk/models/custommessageupdaterequest.py +7 -2
- syllable_sdk/models/{schemas_tts_v1_pronunciations_dictionarymetadata.py → dictionarymetadata.py} +2 -2
- syllable_sdk/models/directory_member_createop.py +28 -0
- syllable_sdk/models/directory_member_downloadop.py +21 -0
- syllable_sdk/models/directory_member_get_by_idop.py +12 -2
- syllable_sdk/models/directory_member_listop.py +28 -18
- syllable_sdk/models/directory_member_updateop.py +17 -2
- syllable_sdk/models/directoryresponseformat.py +11 -0
- syllable_sdk/models/eventtaskevents.py +1 -4
- syllable_sdk/models/expressiontask.py +2 -2
- syllable_sdk/models/expressiontaskevents.py +4 -6
- syllable_sdk/models/getvalueaction.py +151 -0
- syllable_sdk/models/pronunciationoverridesdictionary.py +3 -6
- syllable_sdk/models/stepeventactions.py +14 -7
- syllable_sdk/models/toolparametertransform.py +5 -3
- syllable_sdk/pronunciations.py +4 -8
- syllable_sdk/types/basemodel.py +41 -3
- {syllable_sdk-0.44.4.dist-info → syllable_sdk-0.44.17.dist-info}/METADATA +39 -39
- {syllable_sdk-0.44.4.dist-info → syllable_sdk-0.44.17.dist-info}/RECORD +30 -27
- syllable_sdk/models/schemas_cortex_v1_bridge_phrases_dictionarymetadata.py +0 -67
- {syllable_sdk-0.44.4.dist-info → syllable_sdk-0.44.17.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .caseexpression import CaseExpression, CaseExpressionTypedDict
|
|
5
|
+
from .celexpression import CelExpression, CelExpressionTypedDict
|
|
6
|
+
from .jmespathexpression import JMESPathExpression, JMESPathExpressionTypedDict
|
|
7
|
+
from enum import Enum
|
|
8
|
+
import pydantic
|
|
9
|
+
from pydantic import Discriminator, Tag, model_serializer
|
|
10
|
+
from syllable_sdk.types import (
|
|
11
|
+
BaseModel,
|
|
12
|
+
Nullable,
|
|
13
|
+
OptionalNullable,
|
|
14
|
+
UNSET,
|
|
15
|
+
UNSET_SENTINEL,
|
|
16
|
+
)
|
|
17
|
+
from syllable_sdk.utils import get_discriminator
|
|
18
|
+
from typing import Any, List, Optional, Union
|
|
19
|
+
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
GetValueActionValueFrom1TypedDict = TypeAliasType(
|
|
23
|
+
"GetValueActionValueFrom1TypedDict",
|
|
24
|
+
Union[CelExpressionTypedDict, JMESPathExpressionTypedDict],
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
GetValueActionValueFrom1 = Annotated[
|
|
29
|
+
Union[
|
|
30
|
+
Annotated[CelExpression, Tag("cel")],
|
|
31
|
+
Annotated[JMESPathExpression, Tag("jmespath")],
|
|
32
|
+
Annotated[JMESPathExpression, Tag("jp")],
|
|
33
|
+
],
|
|
34
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
GetValueActionValueFrom2TypedDict = TypeAliasType(
|
|
39
|
+
"GetValueActionValueFrom2TypedDict",
|
|
40
|
+
Union[CaseExpressionTypedDict, GetValueActionValueFrom1TypedDict, str],
|
|
41
|
+
)
|
|
42
|
+
r"""Expression to compute initial value (mutually exclusive with value)."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
GetValueActionValueFrom2 = TypeAliasType(
|
|
46
|
+
"GetValueActionValueFrom2", Union[CaseExpression, GetValueActionValueFrom1, str]
|
|
47
|
+
)
|
|
48
|
+
r"""Expression to compute initial value (mutually exclusive with value)."""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
GetValueActionIf1TypedDict = TypeAliasType(
|
|
52
|
+
"GetValueActionIf1TypedDict",
|
|
53
|
+
Union[CelExpressionTypedDict, JMESPathExpressionTypedDict],
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
GetValueActionIf1 = Annotated[
|
|
58
|
+
Union[
|
|
59
|
+
Annotated[CelExpression, Tag("cel")],
|
|
60
|
+
Annotated[JMESPathExpression, Tag("jmespath")],
|
|
61
|
+
Annotated[JMESPathExpression, Tag("jp")],
|
|
62
|
+
],
|
|
63
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
GetValueActionIf2TypedDict = TypeAliasType(
|
|
68
|
+
"GetValueActionIf2TypedDict",
|
|
69
|
+
Union[CaseExpressionTypedDict, GetValueActionIf1TypedDict, str],
|
|
70
|
+
)
|
|
71
|
+
r"""An expression that must evaluate to true for the action to be applied."""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
GetValueActionIf2 = TypeAliasType(
|
|
75
|
+
"GetValueActionIf2", Union[CaseExpression, GetValueActionIf1, str]
|
|
76
|
+
)
|
|
77
|
+
r"""An expression that must evaluate to true for the action to be applied."""
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class GetValueActionAction(str, Enum):
|
|
81
|
+
r"""Populate default input values."""
|
|
82
|
+
|
|
83
|
+
GET = "get"
|
|
84
|
+
LOAD = "load"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class GetValueActionTypedDict(TypedDict):
|
|
88
|
+
value: NotRequired[Nullable[Any]]
|
|
89
|
+
r"""Initial value of the variable."""
|
|
90
|
+
value_from: NotRequired[Nullable[GetValueActionValueFrom2TypedDict]]
|
|
91
|
+
r"""Expression to compute initial value (mutually exclusive with value)."""
|
|
92
|
+
if_: NotRequired[Nullable[GetValueActionIf2TypedDict]]
|
|
93
|
+
r"""An expression that must evaluate to true for the action to be applied."""
|
|
94
|
+
action: NotRequired[GetValueActionAction]
|
|
95
|
+
r"""Populate default input values."""
|
|
96
|
+
inputs: NotRequired[Nullable[List[str]]]
|
|
97
|
+
r"""Input field names to populate; None populates all step inputs."""
|
|
98
|
+
overwrite: NotRequired[bool]
|
|
99
|
+
r"""If False (default), only populate empty inputs. If True, always overwrite."""
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class GetValueAction(BaseModel):
|
|
103
|
+
value: OptionalNullable[Any] = UNSET
|
|
104
|
+
r"""Initial value of the variable."""
|
|
105
|
+
|
|
106
|
+
value_from: OptionalNullable[GetValueActionValueFrom2] = UNSET
|
|
107
|
+
r"""Expression to compute initial value (mutually exclusive with value)."""
|
|
108
|
+
|
|
109
|
+
if_: Annotated[OptionalNullable[GetValueActionIf2], pydantic.Field(alias="if")] = (
|
|
110
|
+
UNSET
|
|
111
|
+
)
|
|
112
|
+
r"""An expression that must evaluate to true for the action to be applied."""
|
|
113
|
+
|
|
114
|
+
action: Optional[GetValueActionAction] = GetValueActionAction.GET
|
|
115
|
+
r"""Populate default input values."""
|
|
116
|
+
|
|
117
|
+
inputs: OptionalNullable[List[str]] = UNSET
|
|
118
|
+
r"""Input field names to populate; None populates all step inputs."""
|
|
119
|
+
|
|
120
|
+
overwrite: Optional[bool] = False
|
|
121
|
+
r"""If False (default), only populate empty inputs. If True, always overwrite."""
|
|
122
|
+
|
|
123
|
+
@model_serializer(mode="wrap")
|
|
124
|
+
def serialize_model(self, handler):
|
|
125
|
+
optional_fields = ["value", "value_from", "if", "action", "inputs", "overwrite"]
|
|
126
|
+
nullable_fields = ["value", "value_from", "if", "inputs"]
|
|
127
|
+
null_default_fields = []
|
|
128
|
+
|
|
129
|
+
serialized = handler(self)
|
|
130
|
+
|
|
131
|
+
m = {}
|
|
132
|
+
|
|
133
|
+
for n, f in type(self).model_fields.items():
|
|
134
|
+
k = f.alias or n
|
|
135
|
+
val = serialized.get(k)
|
|
136
|
+
serialized.pop(k, None)
|
|
137
|
+
|
|
138
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
139
|
+
is_set = (
|
|
140
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
141
|
+
or k in null_default_fields
|
|
142
|
+
) # pylint: disable=no-member
|
|
143
|
+
|
|
144
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
145
|
+
m[k] = val
|
|
146
|
+
elif val != UNSET_SENTINEL and (
|
|
147
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
148
|
+
):
|
|
149
|
+
m[k] = val
|
|
150
|
+
|
|
151
|
+
return m
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
+
from .dictionarymetadata import DictionaryMetadata, DictionaryMetadataTypedDict
|
|
4
5
|
from .pronunciationoverride import PronunciationOverride, PronunciationOverrideTypedDict
|
|
5
|
-
from .schemas_tts_v1_pronunciations_dictionarymetadata import (
|
|
6
|
-
SchemasTtsV1PronunciationsDictionaryMetadata,
|
|
7
|
-
SchemasTtsV1PronunciationsDictionaryMetadataTypedDict,
|
|
8
|
-
)
|
|
9
6
|
from .voicedisplayinfo import VoiceDisplayInfo, VoiceDisplayInfoTypedDict
|
|
10
7
|
from syllable_sdk.types import BaseModel
|
|
11
8
|
from typing import Dict, List, Optional
|
|
@@ -35,7 +32,7 @@ class PronunciationOverridesDictionaryTypedDict(TypedDict):
|
|
|
35
32
|
"""
|
|
36
33
|
|
|
37
34
|
pronunciations: List[PronunciationOverrideTypedDict]
|
|
38
|
-
metadata:
|
|
35
|
+
metadata: DictionaryMetadataTypedDict
|
|
39
36
|
r"""Audit metadata associated with a dictionary."""
|
|
40
37
|
type: NotRequired[str]
|
|
41
38
|
voices: NotRequired[Dict[str, VoiceDisplayInfoTypedDict]]
|
|
@@ -65,7 +62,7 @@ class PronunciationOverridesDictionary(BaseModel):
|
|
|
65
62
|
|
|
66
63
|
pronunciations: List[PronunciationOverride]
|
|
67
64
|
|
|
68
|
-
metadata:
|
|
65
|
+
metadata: DictionaryMetadata
|
|
69
66
|
r"""Audit metadata associated with a dictionary."""
|
|
70
67
|
|
|
71
68
|
type: Optional[str] = "pronunciations_v1"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .callaction import CallAction, CallActionTypedDict
|
|
5
|
+
from .getvalueaction import GetValueAction, GetValueActionTypedDict
|
|
5
6
|
from .incrementaction import IncrementAction, IncrementActionTypedDict
|
|
6
7
|
from .saveaction import SaveAction, SaveActionTypedDict
|
|
7
8
|
from .sayaction import SayAction, SayActionTypedDict
|
|
@@ -22,9 +23,8 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
|
22
23
|
StepEventActionsStartTypedDict = TypeAliasType(
|
|
23
24
|
"StepEventActionsStartTypedDict",
|
|
24
25
|
Union[
|
|
25
|
-
SayActionTypedDict,
|
|
26
|
-
SaveActionTypedDict,
|
|
27
26
|
IncrementActionTypedDict,
|
|
27
|
+
SayActionTypedDict,
|
|
28
28
|
SetValueActionTypedDict,
|
|
29
29
|
CallActionTypedDict,
|
|
30
30
|
],
|
|
@@ -35,7 +35,6 @@ StepEventActionsStart = Annotated[
|
|
|
35
35
|
Union[
|
|
36
36
|
Annotated[CallAction, Tag("call")],
|
|
37
37
|
Annotated[IncrementAction, Tag("inc")],
|
|
38
|
-
Annotated[SaveAction, Tag("save")],
|
|
39
38
|
Annotated[SayAction, Tag("say")],
|
|
40
39
|
Annotated[SetValueAction, Tag("set")],
|
|
41
40
|
],
|
|
@@ -48,9 +47,9 @@ EnterTypedDict = TypeAliasType(
|
|
|
48
47
|
Union[
|
|
49
48
|
IncrementActionTypedDict,
|
|
50
49
|
SayActionTypedDict,
|
|
51
|
-
SaveActionTypedDict,
|
|
52
50
|
SetValueActionTypedDict,
|
|
53
51
|
CallActionTypedDict,
|
|
52
|
+
GetValueActionTypedDict,
|
|
54
53
|
],
|
|
55
54
|
)
|
|
56
55
|
|
|
@@ -58,8 +57,9 @@ EnterTypedDict = TypeAliasType(
|
|
|
58
57
|
Enter = Annotated[
|
|
59
58
|
Union[
|
|
60
59
|
Annotated[CallAction, Tag("call")],
|
|
60
|
+
Annotated[GetValueAction, Tag("get")],
|
|
61
61
|
Annotated[IncrementAction, Tag("inc")],
|
|
62
|
-
Annotated[
|
|
62
|
+
Annotated[GetValueAction, Tag("load")],
|
|
63
63
|
Annotated[SayAction, Tag("say")],
|
|
64
64
|
Annotated[SetValueAction, Tag("set")],
|
|
65
65
|
],
|
|
@@ -69,13 +69,20 @@ Enter = Annotated[
|
|
|
69
69
|
|
|
70
70
|
PresubmitTypedDict = TypeAliasType(
|
|
71
71
|
"PresubmitTypedDict",
|
|
72
|
-
Union[
|
|
72
|
+
Union[
|
|
73
|
+
IncrementActionTypedDict,
|
|
74
|
+
SaveActionTypedDict,
|
|
75
|
+
SetValueActionTypedDict,
|
|
76
|
+
GetValueActionTypedDict,
|
|
77
|
+
],
|
|
73
78
|
)
|
|
74
79
|
|
|
75
80
|
|
|
76
81
|
Presubmit = Annotated[
|
|
77
82
|
Union[
|
|
83
|
+
Annotated[GetValueAction, Tag("get")],
|
|
78
84
|
Annotated[IncrementAction, Tag("inc")],
|
|
85
|
+
Annotated[GetValueAction, Tag("load")],
|
|
79
86
|
Annotated[SaveAction, Tag("save")],
|
|
80
87
|
Annotated[SetValueAction, Tag("set")],
|
|
81
88
|
],
|
|
@@ -87,8 +94,8 @@ StepEventActionsSubmitTypedDict = TypeAliasType(
|
|
|
87
94
|
"StepEventActionsSubmitTypedDict",
|
|
88
95
|
Union[
|
|
89
96
|
IncrementActionTypedDict,
|
|
90
|
-
SayActionTypedDict,
|
|
91
97
|
SaveActionTypedDict,
|
|
98
|
+
SayActionTypedDict,
|
|
92
99
|
SetValueActionTypedDict,
|
|
93
100
|
CallActionTypedDict,
|
|
94
101
|
],
|
|
@@ -19,7 +19,7 @@ from typing import Any, Optional
|
|
|
19
19
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class ToolParameterTransformAction(str, Enum):
|
|
23
23
|
r"""The action to perform on the tool parameter value: `default` means only set the value (using the `format` field) if the parameter doesn't exist or is empty, `override` means always set the value,\" and `remove` means \"remove the parameter value.\" """
|
|
24
24
|
|
|
25
25
|
DEFAULT = "default"
|
|
@@ -35,7 +35,7 @@ class ToolParameterTransformTypedDict(TypedDict):
|
|
|
35
35
|
- `format` is a string composed of other parameters or context variables.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
|
-
action: NotRequired[
|
|
38
|
+
action: NotRequired[ToolParameterTransformAction]
|
|
39
39
|
r"""The action to perform on the tool parameter value: `default` means only set the value (using the `format` field) if the parameter doesn't exist or is empty, `override` means always set the value,\" and `remove` means \"remove the parameter value.\" """
|
|
40
40
|
when: NotRequired[Nullable[ToolParameterTransformConditionTypedDict]]
|
|
41
41
|
r"""Only apply the transform if the condition is met."""
|
|
@@ -53,7 +53,9 @@ class ToolParameterTransform(BaseModel):
|
|
|
53
53
|
- `format` is a string composed of other parameters or context variables.
|
|
54
54
|
"""
|
|
55
55
|
|
|
56
|
-
action: Optional[
|
|
56
|
+
action: Optional[ToolParameterTransformAction] = (
|
|
57
|
+
ToolParameterTransformAction.DEFAULT
|
|
58
|
+
)
|
|
57
59
|
r"""The action to perform on the tool parameter value: `default` means only set the value (using the `format` field) if the parameter doesn't exist or is empty, `override` means always set the value,\" and `remove` means \"remove the parameter value.\" """
|
|
58
60
|
|
|
59
61
|
when: OptionalNullable[ToolParameterTransformCondition] = UNSET
|
syllable_sdk/pronunciations.py
CHANGED
|
@@ -172,7 +172,7 @@ class Pronunciations(BaseSDK):
|
|
|
172
172
|
server_url: Optional[str] = None,
|
|
173
173
|
timeout_ms: Optional[int] = None,
|
|
174
174
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
175
|
-
) -> models.
|
|
175
|
+
) -> models.DictionaryMetadata:
|
|
176
176
|
r"""Get Pronunciations Metadata
|
|
177
177
|
|
|
178
178
|
:param retries: Override the default retry configuration for this method
|
|
@@ -230,9 +230,7 @@ class Pronunciations(BaseSDK):
|
|
|
230
230
|
)
|
|
231
231
|
|
|
232
232
|
if utils.match_response(http_res, "200", "application/json"):
|
|
233
|
-
return unmarshal_json_response(
|
|
234
|
-
models.SchemasTtsV1PronunciationsDictionaryMetadata, http_res
|
|
235
|
-
)
|
|
233
|
+
return unmarshal_json_response(models.DictionaryMetadata, http_res)
|
|
236
234
|
if utils.match_response(http_res, "4XX", "*"):
|
|
237
235
|
http_res_text = utils.stream_to_text(http_res)
|
|
238
236
|
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
@@ -249,7 +247,7 @@ class Pronunciations(BaseSDK):
|
|
|
249
247
|
server_url: Optional[str] = None,
|
|
250
248
|
timeout_ms: Optional[int] = None,
|
|
251
249
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
252
|
-
) -> models.
|
|
250
|
+
) -> models.DictionaryMetadata:
|
|
253
251
|
r"""Get Pronunciations Metadata
|
|
254
252
|
|
|
255
253
|
:param retries: Override the default retry configuration for this method
|
|
@@ -307,9 +305,7 @@ class Pronunciations(BaseSDK):
|
|
|
307
305
|
)
|
|
308
306
|
|
|
309
307
|
if utils.match_response(http_res, "200", "application/json"):
|
|
310
|
-
return unmarshal_json_response(
|
|
311
|
-
models.SchemasTtsV1PronunciationsDictionaryMetadata, http_res
|
|
312
|
-
)
|
|
308
|
+
return unmarshal_json_response(models.DictionaryMetadata, http_res)
|
|
313
309
|
if utils.match_response(http_res, "4XX", "*"):
|
|
314
310
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
315
311
|
raise errors.APIError("API error occurred", http_res, http_res_text)
|
syllable_sdk/types/basemodel.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from pydantic import ConfigDict, model_serializer
|
|
4
4
|
from pydantic import BaseModel as PydanticBaseModel
|
|
5
|
-
from
|
|
5
|
+
from pydantic_core import core_schema
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, Union
|
|
6
7
|
from typing_extensions import TypeAliasType, TypeAlias
|
|
7
8
|
|
|
8
9
|
|
|
@@ -35,5 +36,42 @@ else:
|
|
|
35
36
|
"OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
|
|
36
37
|
)
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
UnrecognizedStr:
|
|
39
|
+
|
|
40
|
+
class UnrecognizedStr(str):
|
|
41
|
+
@classmethod
|
|
42
|
+
def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
|
|
43
|
+
# Make UnrecognizedStr only work in lax mode, not strict mode
|
|
44
|
+
# This makes it a "fallback" option when more specific types (like Literals) don't match
|
|
45
|
+
def validate_lax(v: Any) -> 'UnrecognizedStr':
|
|
46
|
+
if isinstance(v, cls):
|
|
47
|
+
return v
|
|
48
|
+
return cls(str(v))
|
|
49
|
+
|
|
50
|
+
# Use lax_or_strict_schema where strict always fails
|
|
51
|
+
# This forces Pydantic to prefer other union members in strict mode
|
|
52
|
+
# and only fall back to UnrecognizedStr in lax mode
|
|
53
|
+
return core_schema.lax_or_strict_schema(
|
|
54
|
+
lax_schema=core_schema.chain_schema([
|
|
55
|
+
core_schema.str_schema(),
|
|
56
|
+
core_schema.no_info_plain_validator_function(validate_lax)
|
|
57
|
+
]),
|
|
58
|
+
strict_schema=core_schema.none_schema(), # Always fails in strict mode
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class UnrecognizedInt(int):
|
|
63
|
+
@classmethod
|
|
64
|
+
def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
|
|
65
|
+
# Make UnrecognizedInt only work in lax mode, not strict mode
|
|
66
|
+
# This makes it a "fallback" option when more specific types (like Literals) don't match
|
|
67
|
+
def validate_lax(v: Any) -> 'UnrecognizedInt':
|
|
68
|
+
if isinstance(v, cls):
|
|
69
|
+
return v
|
|
70
|
+
return cls(int(v))
|
|
71
|
+
return core_schema.lax_or_strict_schema(
|
|
72
|
+
lax_schema=core_schema.chain_schema([
|
|
73
|
+
core_schema.int_schema(),
|
|
74
|
+
core_schema.no_info_plain_validator_function(validate_lax)
|
|
75
|
+
]),
|
|
76
|
+
strict_schema=core_schema.none_schema(), # Always fails in strict mode
|
|
77
|
+
)
|