Passed
Push — main ( 853695...d18ab9 )
by Máté
03:41 queued 02:14
created

quiz_element.QuizElement.__str__()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
# noinspection PyPackages
2
from .illustrations.illustration import Illustration  # type: ignore
3
4
5
class QuizElement:
6
    def __init__(
7
        self,
8
        text: str,
9
        illustration: Illustration | None = None,
10
    ) -> None:
11
        assert isinstance(text, str)
12
        self.text = text
13
14
        if illustration:
15
            assert isinstance(illustration, Illustration)
16
        self.illustration = illustration
17
18
    def __str__(self) -> str:
19
        text = self.text
20
        if self.illustration:
21
            text += str(self.illustration)
22
        return text
23