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(
127127 )
128128
129129
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+
130146def _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
131152 if inspect .isclass (tpe ) and _check_parent (tpe , api .BaseModel ):
132153 assert tpe .__name__ == 'Output' , 'output type must be named Output'
133154 fields = {}
@@ -141,7 +162,6 @@ def _output_adt(tpe: type) -> adt.Output:
141162
142163 origin = typing .get_origin (tpe )
143164 kind = None
144- ft = None
145165 if origin in {typing .get_origin (Iterator ), typing .get_origin (AsyncIterator )}:
146166 kind = adt .Kind .ITERATOR
147167 t_args = typing .get_args (tpe )
You can’t perform that action at this time.
0 commit comments