Skip to content

Commit 30b5ff3

Browse files
authored
Change AST for Pydantic 2.10 compatibility (#190)
1 parent 854402d commit 30b5ff3

File tree

4 files changed

+6
-80
lines changed

4 files changed

+6
-80
lines changed

src/pdl/pdl-schema.json

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@
449449
"kind": {
450450
"const": "array",
451451
"default": "array",
452-
"enum": [
453-
"array"
454-
],
455452
"title": "Kind",
456453
"type": "string"
457454
},
@@ -1072,9 +1069,6 @@
10721069
"kind": {
10731070
"const": "model",
10741071
"default": "model",
1075-
"enum": [
1076-
"model"
1077-
],
10781072
"title": "Kind",
10791073
"type": "string"
10801074
},
@@ -1345,9 +1339,6 @@
13451339
},
13461340
"platform": {
13471341
"const": "bam",
1348-
"enum": [
1349-
"bam"
1350-
],
13511342
"title": "Platform",
13521343
"type": "string"
13531344
},
@@ -2086,9 +2077,6 @@
20862077
"kind": {
20872078
"const": "call",
20882079
"default": "call",
2089-
"enum": [
2090-
"call"
2091-
],
20922080
"title": "Kind",
20932081
"type": "string"
20942082
},
@@ -2721,9 +2709,6 @@
27212709
"kind": {
27222710
"const": "code",
27232711
"default": "code",
2724-
"enum": [
2725-
"code"
2726-
],
27272712
"title": "Kind",
27282713
"type": "string"
27292714
},
@@ -3381,9 +3366,6 @@
33813366
"kind": {
33823367
"const": "data",
33833368
"default": "data",
3384-
"enum": [
3385-
"data"
3386-
],
33873369
"title": "Kind",
33883370
"type": "string"
33893371
},
@@ -3861,9 +3843,6 @@
38613843
"kind": {
38623844
"const": "empty",
38633845
"default": "empty",
3864-
"enum": [
3865-
"empty"
3866-
],
38673846
"title": "Kind",
38683847
"type": "string"
38693848
}
@@ -4319,9 +4298,6 @@
43194298
"kind": {
43204299
"const": "error",
43214300
"default": "error",
4322-
"enum": [
4323-
"error"
4324-
],
43254301
"title": "Kind",
43264302
"type": "string"
43274303
},
@@ -4948,9 +4924,6 @@
49484924
"kind": {
49494925
"const": "for",
49504926
"default": "for",
4951-
"enum": [
4952-
"for"
4953-
],
49544927
"title": "Kind",
49554928
"type": "string"
49564929
},
@@ -5771,9 +5744,6 @@
57715744
"kind": {
57725745
"const": "function",
57735746
"default": "function",
5774-
"enum": [
5775-
"function"
5776-
],
57775747
"title": "Kind",
57785748
"type": "string"
57795749
},
@@ -6421,9 +6391,6 @@
64216391
"kind": {
64226392
"const": "get",
64236393
"default": "get",
6424-
"enum": [
6425-
"get"
6426-
],
64276394
"title": "Kind",
64286395
"type": "string"
64296396
},
@@ -6888,9 +6855,6 @@
68886855
"kind": {
68896856
"const": "if",
68906857
"default": "if",
6891-
"enum": [
6892-
"if"
6893-
],
68946858
"title": "Kind",
68956859
"type": "string"
68966860
},
@@ -7694,9 +7658,6 @@
76947658
"kind": {
76957659
"const": "include",
76967660
"default": "include",
7697-
"enum": [
7698-
"include"
7699-
],
77007661
"title": "Kind",
77017662
"type": "string"
77027663
},
@@ -7881,9 +7842,6 @@
78817842
"as": {
78827843
"const": "array",
78837844
"description": "Return the result of each iteration as an array.\n ",
7884-
"enum": [
7885-
"array"
7886-
],
78877845
"title": "As",
78887846
"type": "string"
78897847
}
@@ -7900,9 +7858,6 @@
79007858
"as": {
79017859
"const": "lastOf",
79027860
"description": "Return the result of the last iteration.\n ",
7903-
"enum": [
7904-
"lastOf"
7905-
],
79067861
"title": "As",
79077862
"type": "string"
79087863
}
@@ -7920,9 +7875,6 @@
79207875
"const": "text",
79217876
"default": "text",
79227877
"description": "String concatenation of the result of each iteration.\n ",
7923-
"enum": [
7924-
"text"
7925-
],
79267878
"title": "As",
79277879
"type": "string"
79287880
},
@@ -8385,9 +8337,6 @@
83858337
"kind": {
83868338
"const": "lastOf",
83878339
"default": "lastOf",
8388-
"enum": [
8389-
"lastOf"
8390-
],
83918340
"title": "Kind",
83928341
"type": "string"
83938342
},
@@ -9042,9 +8991,6 @@
90428991
"kind": {
90438992
"const": "model",
90448993
"default": "model",
9045-
"enum": [
9046-
"model"
9047-
],
90488994
"title": "Kind",
90498995
"type": "string"
90508996
},
@@ -9316,9 +9262,6 @@
93169262
"platform": {
93179263
"const": "litellm",
93189264
"default": "litellm",
9319-
"enum": [
9320-
"litellm"
9321-
],
93229265
"title": "Platform",
93239266
"type": "string"
93249267
},
@@ -10220,9 +10163,6 @@
1022010163
"kind": {
1022110164
"const": "message",
1022210165
"default": "message",
10223-
"enum": [
10224-
"message"
10225-
],
1022610166
"title": "Kind",
1022710167
"type": "string"
1022810168
},
@@ -11117,9 +11057,6 @@
1111711057
"kind": {
1111811058
"const": "object",
1111911059
"default": "object",
11120-
"enum": [
11121-
"object"
11122-
],
1112311060
"title": "Kind",
1112411061
"type": "string"
1112511062
},
@@ -12455,9 +12392,6 @@
1245512392
"kind": {
1245612393
"const": "read",
1245712394
"default": "read",
12458-
"enum": [
12459-
"read"
12460-
],
1246112395
"title": "Kind",
1246212396
"type": "string"
1246312397
},
@@ -12996,9 +12930,6 @@
1299612930
"kind": {
1299712931
"const": "repeat",
1299812932
"default": "repeat",
12999-
"enum": [
13000-
"repeat"
13001-
],
1300212933
"title": "Kind",
1300312934
"type": "string"
1300412935
},
@@ -13819,9 +13750,6 @@
1381913750
"kind": {
1382013751
"const": "repeat_until",
1382113752
"default": "repeat_until",
13822-
"enum": [
13823-
"repeat_until"
13824-
],
1382513753
"title": "Kind",
1382613754
"type": "string"
1382713755
},
@@ -14641,9 +14569,6 @@
1464114569
"kind": {
1464214570
"const": "text",
1464314571
"default": "text",
14644-
"enum": [
14645-
"text"
14646-
],
1464714572
"title": "Kind",
1464814573
"type": "string"
1464914574
},

src/pdl/pdl_ast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33

44
from enum import StrEnum
5-
from typing import Any, Literal, Optional, TypeAlias, Union
5+
from typing import Any, Literal, Optional, Sequence, TypeAlias, Union
66

77
from genai.schema import (
88
DecodingMethod,
@@ -110,7 +110,7 @@ class Block(BaseModel):
110110
assign: Optional[str] = Field(default=None, alias="def")
111111
"""Name of the variable used to store the result of the execution of the block.
112112
"""
113-
contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]] = [
113+
contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] = [
114114
ContributeTarget.RESULT,
115115
ContributeTarget.CONTEXT,
116116
]

src/pdl/pdl_interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def step_block(
305305

306306

307307
def context_in_contribute(block: AdvancedBlockType) -> bool:
308-
if ContributeTarget.CONTEXT in block.contribute:
308+
if ContributeTarget.CONTEXT.value in block.contribute:
309309
return True
310310
if get_contribute_value(block.contribute) is not None:
311311
return True

src/pdl/pdl_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from typing import Sequence
23

34
from .pdl_ast import ContributeTarget, ContributeValue, FunctionBlock, Message, Messages
45

@@ -17,7 +18,7 @@ def stringify(result):
1718

1819

1920
def replace_contribute_value(
20-
contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]],
21+
contribute: Sequence[ContributeTarget | dict[str, ContributeValue]],
2122
value: ContributeValue,
2223
):
2324
ret = []
@@ -31,7 +32,7 @@ def replace_contribute_value(
3132

3233

3334
def get_contribute_value(
34-
contribute: list[ContributeTarget | dict[ContributeTarget, ContributeValue]] | None
35+
contribute: Sequence[ContributeTarget | dict[str, ContributeValue]] | None
3536
):
3637
if contribute is None:
3738
return None

0 commit comments

Comments
 (0)