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

pomponchik / symplug / 22206175069

20 Feb 2026 12:30AM UTC coverage: 18.367% (+5.5%) from 12.821%
22206175069

push

github

Евгений Блинов
Big refactoring

17 of 100 new or added lines in 4 files covered. (17.0%)

37 existing lines in 2 files now uncovered.

36 of 196 relevant lines covered (18.37%)

0.55 hits per line

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

13.41
/symplug/components/slot_code_representer.py
1
from functools import cached_property
3✔
2
from inspect import getsource, getmodule
3✔
3
from ast import parse, Pass, Expr, Constant
3✔
4
from typing import Type, Union, Any, Optional, get_args, get_origin, get_type_hints
3✔
5
from importlib.metadata import version, PackageNotFoundError
3✔
6

7
from dill.source import getsource as dill_getsource  # type: ignore[import-untyped]
3✔
8
from denial import InnerNoneType
3✔
9
from packaging.version import Version
3✔
10

11

12
sentinel = InnerNoneType()
3✔
13

14
class SlotCodeRepresenter:
3✔
15
    def __init__(self, function: Callable[..., Any]) -> None:
3✔
16
        self.function = function
×
17

18
    @cached_property
×
19
    def base_module(self) -> str:
×
UNCOV
20
        return getmodule(self.function).__name__.split('.')[0]
×
21

22
    @cached_property
×
UNCOV
23
    def package_version(self) -> Optional[Version]:
×
24
        try:
×
25
            version_identifier = version(self.base_module)
×
26
            return Version(version_identifier)
×
27
        except PackageNotFoundError:
×
UNCOV
28
            return None
×
29

UNCOV
30
    @cached_property
×
31
    def returns_type(self) -> Union[InnerNoneType, Type[Any]]:
×
32
        hints = get_type_hints(self.function)
×
33
        return_hint = hints.get('return', sentinel)
×
34

35
        if return_hint is sentinel:
×
36
            return sentinel
×
37

38
        elif list in (return_hint, get_origin(return_hint)):
×
UNCOV
39
            args = get_args(return_hint)
×
40
            if args:
×
UNCOV
41
                return args[0]
×
42
            else:
43
                return sentinel
×
44

45
        elif dict in (return_hint, get_origin(return_hint)):
×
UNCOV
46
            args = get_args(return_hint)
×
47
            if args:
×
48
                if not args[0] is str or len(args) != 2:
×
UNCOV
49
                    raise TypeError()
×
50
                return args[1]
×
51
            else:
UNCOV
52
                return sentinel
×
53

UNCOV
54
        return return_hint
×
55

56
    @cached_property
×
57
    def returns_list(self) -> bool:
×
58
        hints = get_type_hints(self.function)
×
UNCOV
59
        return_hint = hints.get('return', sentinel)
×
60

61
        if return_hint is sentinel:
×
UNCOV
62
            return False
×
63

64
        elif list in (return_hint, get_origin(return_hint)):
×
UNCOV
65
            return True
×
66

UNCOV
67
        return False
×
68

69
    @cached_property
×
70
    def returns_dict(self) -> bool:
×
71
        hints = get_type_hints(self.function)
×
72
        return_hint = hints.get('return', sentinel)
×
73

UNCOV
74
        if return_hint is sentinel:
×
75
            return False
×
76

77
        elif dict in (return_hint, get_origin(return_hint)):
×
78
            return True
×
79

80
        return False
×
81

82
    @cached_property
×
UNCOV
83
    def is_empty(self) -> bool:
×
84
        try:
×
UNCOV
85
            source_code: str = getsource(self.function)
×
86
        except OSError:
×
87
            source_code = dill_getsource(self.function)
×
88

UNCOV
89
        converted_source_code = self._clear_spaces_from_source_code(source_code)
×
90

91
        tree = parse(converted_source_code)
×
92
        body = tree.body[0].body
×
93

UNCOV
94
        for body_statement in body:
×
95
            if not (isinstance(body_statement, Pass) or (isinstance(body_statement, Expr) and isinstance(body_statement.value, Constant) and (body_statement.value.value is Ellipsis or isinstance(body_statement.value.value, str)))):
×
UNCOV
96
                return False
×
97

UNCOV
98
        return True
×
99

UNCOV
100
    @staticmethod
×
UNCOV
101
    def _clear_spaces_from_source_code(source_code: str) -> str:
×
UNCOV
102
        splitted_source_code = source_code.split('\n')
×
103

UNCOV
104
        indent = 0
×
UNCOV
105
        for letter in splitted_source_code[0]:
×
UNCOV
106
            if letter.isspace():
×
UNCOV
107
                indent += 1
×
108
            else:
UNCOV
109
                break
×
110

UNCOV
111
        new_splitted_source_code = [x[indent:] for x in splitted_source_code]
×
112

UNCOV
113
        return '\n'.join(new_splitted_source_code)
×
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