misc.python.materialize.observed_error

 1# Copyright Materialize, Inc. and contributors. All rights reserved.
 2#
 3# Use of this software is governed by the Business Source License
 4# included in the LICENSE file at the root of this repository.
 5#
 6# As of the Change Date specified in that file, in accordance with
 7# the Business Source License, use of this software will be governed
 8# by the Apache License, Version 2.0.
 9
10from dataclasses import dataclass, field
11
12
13@dataclass(unsafe_hash=True)
14class ObservedBaseError:
15    internal_error_type: str
16    occurrences: int = field(init=False, compare=False, hash=False)
17
18    def to_text(self) -> str:
19        raise NotImplementedError
20
21    def to_markdown(self) -> str:
22        raise NotImplementedError
23
24    def occurrences_to_markdown(self) -> str:
25        if self.occurrences < 2:
26            return ""
27
28        return f"\n({self.occurrences} occurrences)"
29
30
31@dataclass(unsafe_hash=True)
32class WithIssue:
33    issue_number: int
34    issue_url: str
35    issue_title: str
@dataclass(unsafe_hash=True)
class ObservedBaseError:
14@dataclass(unsafe_hash=True)
15class ObservedBaseError:
16    internal_error_type: str
17    occurrences: int = field(init=False, compare=False, hash=False)
18
19    def to_text(self) -> str:
20        raise NotImplementedError
21
22    def to_markdown(self) -> str:
23        raise NotImplementedError
24
25    def occurrences_to_markdown(self) -> str:
26        if self.occurrences < 2:
27            return ""
28
29        return f"\n({self.occurrences} occurrences)"
ObservedBaseError(internal_error_type: str)
internal_error_type: str
occurrences: int
def to_text(self) -> str:
19    def to_text(self) -> str:
20        raise NotImplementedError
def to_markdown(self) -> str:
22    def to_markdown(self) -> str:
23        raise NotImplementedError
def occurrences_to_markdown(self) -> str:
25    def occurrences_to_markdown(self) -> str:
26        if self.occurrences < 2:
27            return ""
28
29        return f"\n({self.occurrences} occurrences)"
@dataclass(unsafe_hash=True)
class WithIssue:
32@dataclass(unsafe_hash=True)
33class WithIssue:
34    issue_number: int
35    issue_url: str
36    issue_title: str
WithIssue(issue_number: int, issue_url: str, issue_title: str)
issue_number: int
issue_url: str
issue_title: str