Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed Nov 14, 2023
1 parent 6b1320b commit dca3b8e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ def stringify_invalid(ex: vol.Invalid) -> str:
is to format the path delimited by -> instead of @data[].
"""
path = "->".join(str(m) for m in ex.path)
# This function is an alternative to the stringification done by
# vol.Invalid.__str__, so we need to call Exception.__str__ here
# instead of str(ex)
output = Exception.__str__(ex)
if error_type := ex.error_type:
output += " for " + error_type
Expand All @@ -598,7 +601,7 @@ def humanize_error(
) -> str:
"""Provide a more helpful + complete validation error message.
This is a aodified version of voluptuous.error.Invalid.__str__,
This is a modified version of voluptuous.error.Invalid.__str__,
the modifications make some minor changes to the formatting.
"""
if isinstance(validation_error, vol.MultipleInvalid):
Expand All @@ -611,7 +614,7 @@ def humanize_error(
offending_item_summary = repr(_get_by_path(data, validation_error.path))
if len(offending_item_summary) > max_sub_error_length:
offending_item_summary = (
offending_item_summary[: max_sub_error_length - 3] + "..."
f"{offending_item_summary[: max_sub_error_length - 3]}..."
)
return f"{stringify_invalid(validation_error)}, got {offending_item_summary}"

Expand Down

0 comments on commit dca3b8e

Please sign in to comment.