Passed
Push — dependabot/pip/flake8-bugbear-... ( 82a4d5...16d864 )
by
unknown
02:18
created

DataValidityComment.resolve()   B

Complexity

Conditions 6

Size

Total Lines 16
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nop 2
dl 0
loc 16
rs 8.6666
c 0
b 0
f 0
1
from __future__ import annotations
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
import enum
3
from dataclasses import dataclass
4
from typing import Set, Union
5
6
from mandos.model import CleverEnum, CompoundNotFoundError
7
8
9
class ChemblCompoundLookupError(CompoundNotFoundError):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
10
    """"""
11
12
13
class ActivityRelation(CleverEnum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
14
    lt = enum.auto()
15
    gt = enum.auto()
16
    le = enum.auto()
17
    ge = enum.auto()
18
    eq = enum.auto()
19
    approx = enum.auto()
20
21
    @classmethod
22
    def of(cls, name: Union[int, str]) -> CleverEnum:
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'of' method
Loading history...
23
        return super().of(
24
            {
25
                "<": "lt",
26
                ">": "gt",
27
                "=": "eq",
28
                "~": "approx",
29
                "<=": "le",
30
                ">=": "ge",
31
            }.get(name, name)
32
        )
33
34
35
class DataValidityComment(CleverEnum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
36
    potential_missing_data = enum.auto()
37
    potential_author_error = enum.auto()
38
    manually_validated = enum.auto()
39
    outside_typical_range = enum.auto()
40
    non_standard_unit_for_type = enum.auto()
41
    author_confirmed_error = enum.auto()
42
43
    @classmethod
44
    def resolve(cls, st: str) -> Set[DataValidityComment]:
0 ignored issues
show
Coding Style Naming introduced by
Argument name "st" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
introduced by
Missing function or method docstring
Loading history...
45
        found = set()
46
        for s in st.lower().split(","):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
47
            s = s.strip()
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
48
            if s == "@all":
49
                return set(cls)
50
            if s == "@negative":
51
                match = DataValidityComment.negative_comments()
52
            elif s == "@positive":
53
                match = DataValidityComment.positive_comments()
54
            else:
55
                match = {DataValidityComment.of(s)}
56
            for m in match:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "m" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
57
                found.add(m)
58
        return found
59
60
    @property
61
    def is_positive(self) -> bool:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
62
        return self in DataValidityComment.positive_comments()
63
64
    @property
65
    def is_negative(self) -> bool:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
66
        return self in DataValidityComment.negative_comments()
67
68
    @classmethod
69
    def positive_comments(cls) -> Set[DataValidityComment]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
70
        return {DataValidityComment.manually_validated}
71
72
    @classmethod
73
    def negative_comments(cls) -> Set[DataValidityComment]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
74
        return {
75
            DataValidityComment.potential_missing_data,
76
            DataValidityComment.potential_author_error,
77
            DataValidityComment.outside_typical_range,
78
            DataValidityComment.non_standard_unit_for_type,
79
            DataValidityComment.author_confirmed_error,
80
        }
81
82
83
@dataclass(frozen=True, order=True, repr=True)
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
84
class ChemblCompound:
85
    """"""
86
87
    chid: str
88
    inchikey: str
89
    name: str
90
91
92
class AssayType(enum.Enum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
93
    binding = enum.auto()
94
    functional = enum.auto()
95
    adme = enum.auto()
96
    physicochemical = enum.auto()
97
98
    @property
99
    def character(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
100
        return {
101
            AssayType.binding: "B",
102
            AssayType.functional: "F",
103
            AssayType.adme: "A",
104
            AssayType.physicochemical: "P",
105
        }[self]
106
107
108
__all__ = [
109
    "ChemblCompound",
110
    "ChemblCompoundLookupError",
111
    "DataValidityComment",
112
    "ActivityRelation",
113
    "AssayType",
114
]
115