File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -107,13 +107,19 @@ def from_type(tpe: type):
107107 t_args = typing .get_args (tpe )
108108 assert len (t_args ) == 1 , 'list must have one type argument'
109109 elem_t = t_args [0 ]
110+ # Fail fast to avoid the cryptic "unsupported Cog type" error later with elem_t
111+ nested_t = typing .get_origin (elem_t )
112+ assert nested_t is None , f'List cannot have nested type { nested_t } '
110113 repetition = Repetition .REPEATED
111114 elif typing .get_origin (tpe ) is Union :
112115 t_args = typing .get_args (tpe )
113116 assert len (t_args ) == 2 and type (None ) in t_args , (
114117 f'unsupported union type { tpe } '
115118 )
116119 elem_t = t_args [0 ] if t_args [1 ] is type (None ) else t_args [0 ]
120+ # Fail fast to avoid the cryptic "unsupported Cog type" error later with elem_t
121+ nested_t = typing .get_origin (elem_t )
122+ assert nested_t is None , f'Optional cannot have nested type { nested_t } '
117123 repetition = Repetition .OPTIONAL
118124 else :
119125 elem_t = tpe
You can’t perform that action at this time.
0 commit comments