Skip to content

Commit 87defb2

Browse files
Avoid explosions when given incorrect input
1 parent 896ebb4 commit 87defb2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/replit_river/codegen/typing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,19 @@ def extract_inner_type(value: TypeExpression) -> TypeName:
210210
case ListTypeExpr(nested):
211211
return extract_inner_type(nested)
212212
case LiteralTypeExpr(_):
213-
raise ValueError(f"Unexpected literal type: {value}")
213+
raise ValueError(f"Unexpected literal type: {repr(value)}")
214214
case UnionTypeExpr(_):
215215
raise ValueError(
216-
f"Attempting to extract from a union, currently not possible: {value}"
216+
f"Attempting to extract from a union, currently not possible: {repr(value)}"
217217
)
218218
case OpenUnionTypeExpr(_):
219219
raise ValueError(
220-
f"Attempting to extract from a union, currently not possible: {value}"
220+
f"Attempting to extract from a union, currently not possible: {repr(value)}"
221221
)
222222
case TypeName(name):
223223
return TypeName(name)
224224
case NoneTypeExpr():
225-
raise ValueError(f"Attempting to extract from a literal 'None': {value}")
225+
raise ValueError(f"Attempting to extract from a literal 'None': {repr(value)}")
226226
case other:
227227
assert_never(other)
228228

@@ -233,5 +233,5 @@ def ensure_literal_type(value: TypeExpression) -> TypeName:
233233
return TypeName(name)
234234
case other:
235235
raise ValueError(
236-
f"Unexpected expression when expecting a type name: {other}"
236+
f"Unexpected expression when expecting a type name: {repr(other)}"
237237
)

0 commit comments

Comments
 (0)