answer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 19
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Answer.__init__() 0 7 1
A Answer.__eq__() 0 7 2
A Answer.__hash__() 0 3 1
1
from ...illustrations.illustration import Illustration  # type: ignore
2
from ...quiz_element import QuizElement  # type: ignore
3
4
5
class Answer(QuizElement):
6
    def __init__(
7
        self, text: str, correct: bool, illustration: Illustration | None = None
8
    ) -> None:
9
        super().__init__(text, illustration)
10
11
        assert isinstance(correct, bool)
12
        self.correct = correct
13
14
    def __hash__(self) -> int:
15
        object_hash = hash(frozenset((self.text, self.correct, self.illustration)))
16
        return object_hash
17
18
    def __eq__(self, other: object) -> bool:
19
        if not isinstance(other, Answer):
20
            return False
21
        return (
22
            self.text == other.text
23
            and self.correct == other.correct
24
            and self.illustration == other.illustration
25
        )
26