Passed
Push — master ( b68652...a53b53 )
by Max
01:00
created

raise_for_collision()   A

Complexity

Conditions 2

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
"""Helpers for reasoning about ordering methods."""
2
3
import typing
4
5
6
def _ordering_options_are_valid(
7
    *, eq: bool, order: bool  # pylint: disable=invalid-name
8
):
9
    if order and not eq:
10
        raise ValueError("eq must be true if order is true")
11
12
13
def _can_set_ordering(*, can_set: bool) -> bool:
14
    if not can_set:
15
        raise ValueError("Can't add ordering methods if equality methods are provided.")
16
    return True
17
18
19
def raise_for_collision(collision: typing.Union[bool, None, str], name: str) -> None:
20
    if collision:
21
        raise TypeError(
22
                f"Cannot overwrite attribute {collision} in class "
23
                f"{name}. Consider using functools.total_ordering"
24
            )
25