From b20121e1f31062f890e21115dd0a97142a899c6c Mon Sep 17 00:00:00 2001 From: pgjones Date: Wed, 1 Jan 2025 18:25:30 +0000 Subject: [PATCH] Change to a RuntimeError if neither pydantic nor msgspec are installed As a TypeError is picked up by Quart and turned into a BadRequest, rather than crashing as a programming error. --- src/quart_schema/conversion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quart_schema/conversion.py b/src/quart_schema/conversion.py index eb549ed..7b57249 100644 --- a/src/quart_schema/conversion.py +++ b/src/quart_schema/conversion.py @@ -183,7 +183,7 @@ def model_load( elif _use_msgspec(model_class, preference): return convert(data, model_class, strict=False) elif not PYDANTIC_INSTALLED and not MSGSPEC_INSTALLED: - raise TypeError(f"Cannot load {model_class} - try installing msgspec or pydantic") + raise RuntimeError(f"Cannot load {model_class} - try installing msgspec or pydantic") else: raise TypeError(f"Cannot load {model_class}") except (TypeError, MsgSpecValidationError, PydanticValidationError, ValueError) as error: