Use `object()` when checking for error field value

Since the field value could be `None` or some other type with
truthy-ness evaluating to `False`..
runtime_to_msgspec
Tyler Goodlet 2024-04-07 16:29:21 -04:00
parent aca6503fcd
commit aea5abdd70
1 changed files with 2 additions and 1 deletions

View File

@ -172,7 +172,8 @@ def _raise_msg_type_err(
# specific field's type problem
msgspec_msg: str = validation_err.args[0].rstrip('`')
msg, _, maybe_field = msgspec_msg.rpartition('$.')
if field_val := msg_dict.get(maybe_field):
obj = object()
if (field_val := msg_dict.get(maybe_field, obj)) is not obj:
field_type: Union[Type] = msg_type.__signature__.parameters[
maybe_field
].annotation