Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid polluting ValidationError traceback with printing generate code #24

Merged
merged 3 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/validate_pyproject/error_reporting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io
import json
import logging
import os
import re
from contextlib import contextmanager
from textwrap import indent, wrap
Expand Down Expand Up @@ -61,7 +62,9 @@ class ValidationError(JsonSchemaValueException):
def _from_jsonschema(cls, ex: JsonSchemaValueException):
formatter = _ErrorFormatting(ex)
obj = cls(str(formatter), ex.value, formatter.name, ex.definition, ex.rule)
obj.__cause__, obj.__traceback__ = ex.__cause__, ex.__traceback__
debug_code = os.getenv("JSONSCHEMA_DEBUG_CODE_GENERATION", "false").lower()
if debug_code != "false": # pragma: no cover
obj.__cause__, obj.__traceback__ = ex.__cause__, ex.__traceback__
obj._original_message = ex.message
obj.summary = formatter.summary
obj.details = formatter.details
Expand Down
2 changes: 1 addition & 1 deletion src/validate_pyproject/extra_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def validate_project_dynamic(pyproject: T) -> T:

for field in dynamic:
if field in project_table:
msg = f"You cannot provided a value for `project.{field}` and "
msg = f"You cannot provide a value for `project.{field}` and "
msg += "list it under `project.dynamic` at the same time"
name = f"data.project.{field}"
value = {field: project_table[field], "...": " # ...", "dynamic": dynamic}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
You cannot provided a value for `project.classifiers` and list it under `project.dynamic` at the same time
You cannot provide a value for `project.classifiers` and list it under `project.dynamic` at the same time