core.common: move assert_subpackage to my.core.internal

This commit is contained in:
Dima Gerasimov 2024-08-15 18:49:19 +03:00
parent 7961c9d9b1
commit ac64b08915
9 changed files with 17 additions and 13 deletions

9
my/core/internal.py Normal file
View file

@ -0,0 +1,9 @@
"""
Utils specific to hpi core, shouldn't really be used by HPI modules
"""
def assert_subpackage(name: str) -> None:
# can lead to some unexpected issues if you 'import cachew' which being in my/core directory.. so let's protect against it
# NOTE: if we use overlay, name can be smth like my.origg.my.core.cachew ...
assert name == '__main__' or 'my.core' in name, f'Expected module __name__ ({name}) to be __main__ or start with my.core'