Passed
Branch master (9e8f7a)
by Oleksandr
01:29
created

candv.utils   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 17
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A export() 0 25 4
1
import inspect
2
3
from typing import Any
4
5
6
def export(target: Any) -> Any:
7
  """
8
  Mark a module-level object as exported.
9
10
  Simplifies tracking of objects available via wildcard imports.
11
12
  """
13
  frm = inspect.stack()[1]
14
  mod = inspect.getmodule(frm[0])
15
16
  __all__ = getattr(mod, '__all__', None)
17
18
  if __all__ is None:
19
    __all__ = []
20
    setattr(mod, '__all__', __all__)
21
22
  elif not isinstance(__all__, list):
23
    __all__ = list(__all__)
24
    setattr(mod, '__all__', __all__)
25
26
  target_name = target.__name__
27
  if target_name not in __all__:
28
    __all__.append(target_name)
29
30
  return target
31