| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |