@@ -108,6 +108,10 @@ def expand_pattern(t):
108
108
# If no args were provided, or those arguments were an ellipsis
109
109
assert isinstance (origin , type )
110
110
return origin
111
+ if origin not in (ty .Union , type ) and not issubclass (origin , ty .Iterable ):
112
+ raise TypeError (
113
+ f"Don't know how to handle args ({ args } ) for { origin } type"
114
+ )
111
115
return (origin , [expand_pattern (a ) for a in args ])
112
116
113
117
self .tp = tp
@@ -143,7 +147,7 @@ def __call__(self, obj: ty.Any) -> ty.Union[T, LazyField[T]]:
143
147
coerced = attr .NOTHING # type: ignore[assignment]
144
148
elif isinstance (obj , LazyField ):
145
149
self .check_type (obj .type )
146
- coerced = obj
150
+ coerced = obj # type: ignore
147
151
elif isinstance (obj , StateArray ):
148
152
coerced = StateArray (self (o ) for o in obj ) # type: ignore[assignment]
149
153
else :
@@ -184,14 +188,11 @@ def expand_and_coerce(obj, pattern: ty.Union[type, tuple]):
184
188
raise TypeError (
185
189
f"Could not coerce to { type_ } as { obj } is not iterable{ msg } "
186
190
) from e
187
- if issubclass (origin , ty . Tuple ):
191
+ if issubclass (origin , tuple ):
188
192
return coerce_tuple (type_ , obj_args , pattern_args )
189
193
if issubclass (origin , ty .Iterable ):
190
194
return coerce_sequence (type_ , obj_args , pattern_args )
191
- else :
192
- assert (
193
- False
194
- ), f"Don't know how to handle args ({ pattern_args } ) for { origin } type"
195
+ assert False , f"Coercion from { obj } to { pattern } is not handled"
195
196
196
197
def coerce_basic (obj , pattern ):
197
198
"""Coerce an object to a "basic types" like `int`, `float`, `bool`, `Path`
0 commit comments