File tree Expand file tree Collapse file tree 3 files changed +440
-1
lines changed Expand file tree Collapse file tree 3 files changed +440
-1
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,28 @@ def _input_adt(
127
127
)
128
128
129
129
130
+ # Mimic PrimitiveType behavior to support Any output type
131
+ class AnyType :
132
+ def normalize (self , value : Any ) -> Any :
133
+ return value
134
+
135
+ def json_type (selfself ) -> dict [str , Any ]:
136
+ # Compat: legacy Cog does not even add {"type": "object"}
137
+ return {}
138
+
139
+ def json_encode (self , value : Any ) -> Any :
140
+ return value
141
+
142
+
143
+ _any_type = AnyType ()
144
+
145
+
130
146
def _output_adt (tpe : type ) -> adt .Output :
147
+ if tpe is Any :
148
+ print (
149
+ 'Warning: use of Any as output type is error prone and highly-discouraged'
150
+ )
151
+ return adt .Output (kind = adt .Kind .SINGLE , type = _any_type ) # type: ignore
131
152
if inspect .isclass (tpe ) and _check_parent (tpe , api .BaseModel ):
132
153
assert tpe .__name__ == 'Output' , 'output type must be named Output'
133
154
fields = {}
@@ -141,7 +162,6 @@ def _output_adt(tpe: type) -> adt.Output:
141
162
142
163
origin = typing .get_origin (tpe )
143
164
kind = None
144
- ft = None
145
165
if origin in {typing .get_origin (Iterator ), typing .get_origin (AsyncIterator )}:
146
166
kind = adt .Kind .ITERATOR
147
167
t_args = typing .get_args (tpe )
You can’t perform that action at this time.
0 commit comments