Skip to content

Commit

Permalink
fix: format string errors no longer embed the entire format string (#135
Browse files Browse the repository at this point in the history
)

Problem:

Format strings can be very large (e.g. when they are the 'data' element of an embedded file).
The FormatStringError that we report currently embeds the entire format string into the error
message. That's unnecessary since our validation errors are already pointing the user directly
at the template element that is producing the error.

Solution:

This removes the format string data from the error message.

Signed-off-by: Daniel Neilson <53624638+ddneilson@users.noreply.github.com>
  • Loading branch information
ddneilson authored Aug 14, 2024
1 parent 8640bde commit 5872f7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sync = "pip install -r requirements-testing.txt"
test = "pytest --cov-config pyproject.toml {args:test}"
typing = "mypy {args:src test}"
style = [
"ruff {args:src test}",
"ruff check {args:src test}",
"black --check --diff {args:src test}",
]
fmt = [
Expand Down
3 changes: 1 addition & 2 deletions src/openjd/model/_format_strings/_format_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def __init__(self, *, string: str, start: int, end: int, expr: str = "", details
expression = f"Expression: {expr}. " if expr else ""
reason = f"Reason: {details}." if details else ""
msg = (
f"Failed to parse interpolation expression in {string} "
f"at [{start}, {end}]. "
f"Failed to parse interpolation expression at [{start}, {end}]. "
f"{expression}"
f"{reason}"
)
Expand Down

0 comments on commit 5872f7c

Please sign in to comment.