-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathneedsEnumObject.py
More file actions
123 lines (92 loc) · 2.72 KB
/
needsEnumObject.py
File metadata and controls
123 lines (92 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# ruff: noqa
# Code generated by river.codegen. DO NOT EDIT.
from collections.abc import AsyncIterable, AsyncIterator
import datetime
from typing import (
Any,
Callable,
Dict,
List,
Literal,
Optional,
Mapping,
NotRequired,
Union,
Tuple,
TypedDict,
)
from typing_extensions import Annotated
from pydantic import BaseModel, Field, TypeAdapter, WrapValidator
from replit_river.error_schema import RiverError
from replit_river.client import RiverUnknownValue, translate_unknown_value
import replit_river as river
encode_NeedsenumobjectInputOneOf_in_first: Callable[
["NeedsenumobjectInputOneOf_in_first"], Any
] = lambda x: {
k: v
for (k, v) in (
{
"$kind": x.get("kind"),
"value": x.get("value"),
}
).items()
if v is not None
}
class NeedsenumobjectInputOneOf_in_first(TypedDict):
kind: Literal["in_first"]
value: str
encode_NeedsenumobjectInputOneOf_in_second: Callable[
["NeedsenumobjectInputOneOf_in_second"], Any
] = lambda x: {
k: v
for (k, v) in (
{
"$kind": x.get("kind"),
"bleep": x.get("bleep"),
}
).items()
if v is not None
}
class NeedsenumobjectInputOneOf_in_second(TypedDict):
kind: Literal["in_second"]
bleep: int
NeedsenumobjectInput = (
NeedsenumobjectInputOneOf_in_first | NeedsenumobjectInputOneOf_in_second
)
encode_NeedsenumobjectInput: Callable[["NeedsenumobjectInput"], Any] = (
lambda x: encode_NeedsenumobjectInputOneOf_in_first(x)
if x["kind"] == "in_first"
else encode_NeedsenumobjectInputOneOf_in_second(x)
)
class NeedsenumobjectOutputFooOneOf_out_first(BaseModel):
kind: Literal["out_first"] = Field(
"out_first",
alias="$kind", # type: ignore
)
foo: int
class NeedsenumobjectOutputFooOneOf_out_second(BaseModel):
kind: Literal["out_second"] = Field(
"out_second",
alias="$kind", # type: ignore
)
bar: int
NeedsenumobjectOutputFoo = Annotated[
NeedsenumobjectOutputFooOneOf_out_first
| NeedsenumobjectOutputFooOneOf_out_second
| RiverUnknownValue,
WrapValidator(translate_unknown_value),
]
class NeedsenumobjectOutput(BaseModel):
foo: Optional[NeedsenumobjectOutputFoo] = None
class NeedsenumobjectErrorsFooAnyOf_0(RiverError):
beep: Optional[Literal["err_first"]] = None
class NeedsenumobjectErrorsFooAnyOf_1(RiverError):
borp: Optional[Literal["err_second"]] = None
NeedsenumobjectErrorsFoo = Annotated[
NeedsenumobjectErrorsFooAnyOf_0
| NeedsenumobjectErrorsFooAnyOf_1
| RiverUnknownValue,
WrapValidator(translate_unknown_value),
]
class NeedsenumobjectErrors(RiverError):
foo: Optional[NeedsenumobjectErrorsFoo] = None