core: add helper to 'freeze' dataclasses, in order to derive a schema from the properties

This commit is contained in:
Dima Gerasimov 2021-02-22 21:58:19 +00:00 committed by karlicoss
parent 86497f9b13
commit ca4d58e4e7
5 changed files with 81 additions and 5 deletions

View file

@ -556,3 +556,9 @@ def to_jsons(it) -> Iterable[Json]:
datetime_naive = datetime
datetime_aware = datetime
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 'my.core' in name, f'Expected module __name__ ({name}) to start with my.core'