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

CityOfZion / neo3-boa / 86616b77-8a70-49e8-88fa-6fd3eeb6118a

08 May 2024 04:18PM UTC coverage: 91.921% (-0.08%) from 92.003%
86616b77-8a70-49e8-88fa-6fd3eeb6118a

push

circleci

Mirella de Medeiros
#86dtb6tt0 - Change the usage of `typing` collections to use `collections.abc` and update the tests accordingly

268 of 281 new or added lines in 76 files covered. (95.37%)

197 existing lines in 23 files now uncovered.

20992 of 22837 relevant lines covered (91.92%)

1.84 hits per line

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

95.83
/boa3/internal/model/variable.py
1
import ast
2✔
2
from typing import Any, Self
2✔
3

4
from boa3.internal.model.expression import IExpression
2✔
5
from boa3.internal.model.type.itype import IType
2✔
6

7

8
class Variable(IExpression):
2✔
9
    """
10
    A class used to represent a variable
11

12
    :ivar var_type: the type of the variable.
13
    """
14

15
    def __init__(self,
2✔
16
                 var_type: IType | None,
17
                 origin_node: ast.AST | None = None,
18
                 deprecated: bool = False
19
                 ):
20
        super().__init__(origin_node, deprecated)
2✔
21
        self.defined_by_entry = True
2✔
22

23
        from boa3.internal.analyser.model.optimizer import Undefined, UndefinedType
2✔
24
        if var_type is None:
2✔
25
            var_type = Undefined
2✔
26

27
        self._var_type: IType | UndefinedType = var_type
2✔
28

29
        self.is_reassigned = False
2✔
30
        self._origin_variable: Variable | None = None
2✔
31
        self._first_assign_value: Any = Undefined
2✔
32

33
    def copy(self) -> Self:
2✔
34
        var = Variable(self._var_type, self._origin_node)
2✔
35
        var.is_reassigned = self.is_reassigned
2✔
36
        var._first_assign_value = self._first_assign_value
2✔
37
        var._origin_variable = self._origin_variable if self._origin_variable is not None else self
2✔
38
        return var
2✔
39

40
    @property
2✔
41
    def shadowing_name(self) -> str:
2✔
42
        return 'variable'
2✔
43

44
    @property
2✔
45
    def type(self) -> IType:
2✔
46
        return self._var_type
2✔
47

48
    @property
2✔
49
    def is_global(self) -> bool:
2✔
50
        return hasattr(self, '_set_as_global') and self._set_as_global
2✔
51

52
    @property
2✔
53
    def has_literal_value(self) -> bool:
2✔
54
        from boa3.internal.analyser.model.optimizer import Undefined
2✔
55
        return self._first_assign_value is not Undefined
2✔
56

57
    def __repr__(self) -> str:
2✔
UNCOV
58
        return '{0}({1})'.format(self.__class__.__name__, self.__str__())
×
59

60
    def __str__(self) -> str:
2✔
UNCOV
61
        return str(self.type)
×
62

63
    def set_type(self, var_type: IType):
2✔
64
        """
65
        Sets a type for the variable
66

67
        :param var_type:
68
        """
69
        self._var_type = var_type
2✔
70

71
    def set_is_reassigned(self):
2✔
72
        if not self.is_reassigned:
2✔
73
            self.is_reassigned = True
2✔
74
        if hasattr(self._origin_variable, 'set_is_reassigned'):
2✔
75
            self._origin_variable.set_is_reassigned()
2✔
76

77
    def set_initial_assign(self, first_value: Any):
2✔
78
        if not self.has_literal_value:
2✔
79
            self._first_assign_value = first_value
2✔
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