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):
107
107
t_args = typing .get_args (tpe )
108
108
assert len (t_args ) == 1 , 'list must have one type argument'
109
109
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 } '
110
113
repetition = Repetition .REPEATED
111
114
elif typing .get_origin (tpe ) is Union :
112
115
t_args = typing .get_args (tpe )
113
116
assert len (t_args ) == 2 and type (None ) in t_args , (
114
117
f'unsupported union type { tpe } '
115
118
)
116
119
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 } '
117
123
repetition = Repetition .OPTIONAL
118
124
else :
119
125
elem_t = tpe
You can’t perform that action at this time.
0 commit comments