• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Naapperas / zon / 9598735143

20 Jun 2024 01:52PM UTC coverage: 92.96%. First build
9598735143

Pull #8

github

Naapperas
Re-implemented refinements
Pull Request #8: Refactor/refactor api

503 of 538 new or added lines in 3 files covered. (93.49%)

515 of 554 relevant lines covered (92.96%)

3.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/zon/error.py
1
"""Validation errors for Zons"""
2✔
2

3
from typing import Any
4✔
4
from dataclasses import dataclass
4✔
5

6
from typing_extensions import deprecated
4✔
7

8

9
@deprecated("Use the new ZonError class instead.")
4✔
10
class ValidationError(Exception):
4✔
11
    """
2✔
12
    Validation error thrown when a validation fails.
13

14
    Deprecated:
15
        This class was deprecated in 2.0.0 and will be removed soon. Use ZonError instead.
16
    """
17

18
    def __init__(self, message: str):
4✔
19
        """Builds a new ValidationError with the supplied message.
20

21
        Args:
22
            message (str): The message to be displayed when the exception is thrown.
23
        """
24
        super()
×
25
        self.message = message
×
26

27
    def __str__(self):
4✔
28
        """Used to covert this exception into a string."""
29

30
        return repr(self.message)
×
31

32
    def __repr__(self) -> str:
4✔
33
        """Used to covert this exception into a string."""
34

35
        return f"ValidationError({self.message})"
×
36

37

38
@dataclass(kw_only=True, frozen=True)
4✔
39
class ZonIssue:
4✔
40
    """Some issue with validation"""
2✔
41

42
    value: Any
4✔
43
    message: str
4✔
44
    path: list[str]
4✔
45

46

47
class ZonError(Exception):
4✔
48
    """Validation error thrown when a validation fails."""
2✔
49

50
    issues: list[ZonIssue]
4✔
51

52
    def __init__(self):
4✔
53
        """Builds a new ValidationError with the supplied message.
54

55
        Args:
56
            message (str): The message to be displayed when the exception is thrown.
57
        """
58
        super()
4✔
59
        self.issues = []
4✔
60

61
    def add_issue(self, issue: ZonIssue):
4✔
62
        """Adds an existing issue to this validation error"""
63

64
        self.issues.append(issue)
4✔
65

66
    def add_issues(self, issues: list[ZonIssue]):
4✔
67
        """Adds a batch of existing issues to this validation error"""
68

69
        self.issues.extend(issues)
4✔
70

71
    def __str__(self):
4✔
72
        """Used to covert this exception into a string."""
73

NEW
74
        return repr(self)
×
75

76
    def __repr__(self) -> str:
4✔
77
        """Used to covert this exception into a string."""
78

NEW
79
        return f"""ZonError(
×
80
        issues: {self.issues})
81
        """
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc