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

Refactor(pyavd): Adding path attribute to the validation error for removed keys #4688

Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions python-avd/pyavd/_errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def __init__(
self.message = " ".join(messages)
super().__init__(self.message)

def _as_validation_error(self) -> AvdValidationError:
"""Converting AvdDeprecationWarning to AvdValidationError."""
return AvdValidationError(message=self.message, path=self.path.split("."))


class AristaAvdDuplicateDataError(AristaAvdError):
def __init__(self, context: str, context_item_a: str, context_item_b: str) -> None:
Expand Down
4 changes: 2 additions & 2 deletions python-avd/pyavd/avd_schema_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def convert_data(self, data: dict) -> ValidationResult:
ValidationResult object with any validation errors or deprecation warnings.
"""
# pylint: disable=import-outside-toplevel
from ._errors import AvdDeprecationWarning, AvdValidationError
from ._errors import AvdDeprecationWarning
from .validation_result import ValidationResult

# pylint: enable=import-outside-toplevel
Expand All @@ -64,7 +64,7 @@ def convert_data(self, data: dict) -> ValidationResult:
# Store but continue for deprecations
if isinstance(exception, AvdDeprecationWarning):
if exception.removed or exception.conflict:
result.validation_errors.append(AvdValidationError(exception.message))
result.validation_errors.append(exception._as_validation_error())
result.failed = True
continue

Expand Down
Loading