sdoc.sdoc1.data_type.DataType.DataType.debug()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 8
loc 8
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nop 2
crap 1
1 1
import abc
2 1
from typing import Union
3
4
5 1 View Code Duplication
class DataType(metaclass=abc.ABCMeta):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6
    """
7
    Abstract parent class for all data types.
8
    """
9
10
    # Constants for all data types.
11 1
    INT = 1
12 1
    STRING = 2
13 1
    ARRAY = 3
14
15
    # ------------------------------------------------------------------------------------------------------------------
16 1
    @abc.abstractmethod
17 1
    def debug(self, indent: int = 0) -> str:
18
        """
19
        Returns a string for debugging.
20
21
        :param int indent: The indentation level.
22
        """
23
        raise NotImplementedError
24
25
    # ------------------------------------------------------------------------------------------------------------------
26 1
    @abc.abstractmethod
27 1
    def dereference(self):
28
        """
29
        Returns a clone of this data type.
30
31
        :rtype: sdoc.sdoc1.data_type.DataType.DataType
32
        """
33
        raise NotImplementedError
34
35
    # ------------------------------------------------------------------------------------------------------------------
36 1
    @abc.abstractmethod
37 1
    def get_value(self) -> Union[int, str]:
38
        """
39
        Returns the underling value of this data type.
40
        """
41
        raise NotImplementedError
42
43
    # ------------------------------------------------------------------------------------------------------------------
44 1
    @abc.abstractmethod
45 1
    def get_type_id(self) -> int:
46
        """
47
        Returns the ID of this data type.
48
        """
49
        raise NotImplementedError
50
51
    # ------------------------------------------------------------------------------------------------------------------
52 1
    @abc.abstractmethod
53 1
    def is_constant(self) -> bool:
54
        """
55
        Returns True if this data type is a constant. Returns False otherwise.
56
        """
57
        raise NotImplementedError
58
59
    # ------------------------------------------------------------------------------------------------------------------
60 1
    @abc.abstractmethod
61 1
    def is_defined(self) -> bool:
62
        """
63
        Returns True if this data type is defined, i.e. has a value. Returns False otherwise.
64
        """
65
        raise NotImplementedError
66
67
    # ------------------------------------------------------------------------------------------------------------------
68 1
    @abc.abstractmethod
69 1
    def is_scalar(self) -> bool:
70
        """
71
        Returns True if this data type is a scalar. Returns False otherwise.
72
        """
73
        raise NotImplementedError
74
75
    # ------------------------------------------------------------------------------------------------------------------
76 1
    @abc.abstractmethod
77 1
    def is_true(self) -> bool:
78
        """
79
        Returns True if this data type evaluates to True. Returns False otherwise.
80
        """
81
        raise NotImplementedError
82
83
# ----------------------------------------------------------------------------------------------------------------------
84