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

CityOfZion / neo3-boa / 901be479-27a3-4d37-a8e9-d5889c82bd13

16 Jan 2024 04:06PM UTC coverage: 92.101% (+0.1%) from 91.967%
901be479-27a3-4d37-a8e9-d5889c82bd13

push

circleci

Mirella de Medeiros
CU-86a1n2upk - Notify is not being registered on events when using `notify` as a exported member of another import

20767 of 22548 relevant lines covered (92.1%)

1.84 hits per line

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

95.59
/boa3/internal/model/operation/binaryop.py
1
from typing import List, Optional
2✔
2

3
from boa3.internal.model.operation.binary.additional import *
2✔
4
from boa3.internal.model.operation.binary.arithmetic import *
2✔
5
from boa3.internal.model.operation.binary.binaryoperation import BinaryOperation
2✔
6
from boa3.internal.model.operation.binary.logical import *
2✔
7
from boa3.internal.model.operation.binary.relational import *
2✔
8
from boa3.internal.model.operation.operation import IOperation
2✔
9
from boa3.internal.model.operation.operator import Operator
2✔
10
from boa3.internal.model.operation.unary.noneidentity import NoneIdentity
2✔
11
from boa3.internal.model.operation.unary.nonenotidentity import NoneNotIdentity
2✔
12
from boa3.internal.model.type.itype import IType
2✔
13

14

15
class BinaryOp:
2✔
16
    # Arithmetic operations
17
    Add = Addition()
2✔
18
    Sub = Subtraction()
2✔
19
    Mul = Multiplication()
2✔
20
    Div = Division()
2✔
21
    IntDiv = FloorDivision()
2✔
22
    ListAdd = ListAddition()
2✔
23
    Mod = Modulo()
2✔
24
    Pow = Power()
2✔
25
    Concat = Concat()
2✔
26
    StrBytesMul = StrBytesMultiplication()
2✔
27

28
    # Relational operations
29
    NumEq = NumericEquality()
2✔
30
    NumNotEq = NumericInequality()
2✔
31
    Lt = LessThan()
2✔
32
    LtE = LessThanOrEqual()
2✔
33
    Gt = GreaterThan()
2✔
34
    GtE = GreaterThanOrEqual()
2✔
35
    IsNone = NoneIdentity()
2✔
36
    IsNotNone = NoneNotIdentity()
2✔
37
    Is = Identity()
2✔
38
    IsNot = NotIdentity()
2✔
39
    Eq = ObjectEquality()
2✔
40
    NotEq = ObjectInequality()
2✔
41

42
    # Logical operations
43
    And = BooleanAnd()
2✔
44
    Or = BooleanOr()
2✔
45
    ElvisOperatorOr = ElvisOperatorOr()
2✔
46
    BitAnd = LogicAnd()
2✔
47
    BitOr = LogicOr()
2✔
48
    Xor = LogicXor()
2✔
49
    LShift = LeftShift()
2✔
50
    RShift = RightShift()
2✔
51

52
    # Other operations
53
    In = CollectionMembership()
2✔
54
    NotIn = CollectionNotMembership()
2✔
55

56
    @classmethod
2✔
57
    def validate_type(cls, operator: Operator, left: IType, right: IType) -> Optional[BinaryOperation]:
2✔
58
        """
59
        Gets a binary operation given the operator and the operands types.
60

61
        :param operator: binary operator
62
        :param left: type of the left operand
63
        :param right: type of the right operand
64
        :return: The operation if exists. None otherwise;
65
        :rtype: BinaryOperation or None
66
        """
67
        for id, op in vars(cls).items():
2✔
68
            if isinstance(op, IOperation) and op.is_valid(operator, left, right):
2✔
69
                if isinstance(op, BinaryOperation):
2✔
70
                    return op.build(left, right)
2✔
71
                else:
72
                    from boa3.internal.model.type.type import Type
2✔
73
                    operand = right if left is Type.none else left
2✔
74
                    return op.build(operand)
2✔
75

76
    @classmethod
2✔
77
    def get_operation_by_operator(cls, operator: Operator, left_operand: IType,
2✔
78
                                  right_operand: Optional[IType] = None) -> Optional[BinaryOperation]:
79
        """
80
        Gets a binary operation given the operator.
81

82
        :param operator: binary operator
83
        :param left_operand: left operand of the operator
84
        :param right_operand: right operand of the operator
85
        :return: The operation if exists. If exists more than one operation with the same operator, returns the one with
86
        the same left operand. If none has the same left operand, returns the first found. None otherwise;
87
        :rtype: BinaryOperation or None
88
        """
89
        valid_operations: List[BinaryOperation] = []
2✔
90
        for id, op in vars(cls).items():
2✔
91
            if isinstance(op, BinaryOperation) and op.operator is operator:
2✔
92
                left, right = op.get_valid_operand_for_validation(left_operand, right_operand)
2✔
93
                if left is not None:
2✔
94
                    return op.build(left_operand if right_operand is None else left, right)
2✔
95
                else:
96
                    valid_operations.append(op)
2✔
97

98
        return valid_operations[0] if len(valid_operations) > 0 else None
2✔
99

100
    @classmethod
2✔
101
    def get_operation(cls, operation: BinaryOperation) -> Optional[BinaryOperation]:
2✔
102
        """
103
        Gets a binary operation given another operation.
104

105
        :param operation: binary operation
106
        :return: The operation if exists. None otherwise;
107
        :rtype: BinaryOperation or None
108
        """
109
        for id, op in vars(cls).items():
×
110
            if type(operation) == type(op):
×
111
                return op
×
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