Passed
Push — master ( 0fb205...8fdecd )
by Oleksandr
56s
created

commons._utils   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 16
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A export() 0 24 4
1
import sys
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
  mod = sys.modules[target.__module__]
14
15
  __all__ = getattr(mod, '__all__', None)
16
17
  if __all__ is None:
18
    __all__ = []
19
    setattr(mod, '__all__', __all__)
20
21
  elif not isinstance(__all__, list):
22
    __all__ = list(__all__)
23
    setattr(mod, '__all__', __all__)
24
25
  target_name = target.__name__
26
  if target_name not in __all__:
27
    __all__.append(target_name)
28
29
  return target
30