core.common: move assert_subpackage to my.core.internal
This commit is contained in:
parent
88f3c17c27
commit
7f8a502310
9 changed files with 17 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -173,12 +173,6 @@ def asdict(thing: Any) -> Json:
|
||||||
raise TypeError(f'Could not convert object {thing} to dict')
|
raise TypeError(f'Could not convert object {thing} to dict')
|
||||||
|
|
||||||
|
|
||||||
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'
|
|
||||||
|
|
||||||
|
|
||||||
# TODO deprecate and suggest to use one from my.core directly? not sure
|
# TODO deprecate and suggest to use one from my.core directly? not sure
|
||||||
from .utils.itertools import unique_everseen
|
from .utils.itertools import unique_everseen
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
|
|
||||||
import dataclasses as dcl
|
import dataclasses as dcl
|
||||||
import inspect
|
import inspect
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'''
|
'''
|
||||||
TODO doesn't really belong to 'core' morally, but can think of moving out later
|
TODO doesn't really belong to 'core' morally, but can think of moving out later
|
||||||
'''
|
'''
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
|
||||||
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
|
|
||||||
from typing import Iterable, Any, Optional, Dict
|
from typing import Iterable, Any, Optional, Dict
|
||||||
|
|
||||||
|
|
9
my/core/internal.py
Normal file
9
my/core/internal.py
Normal 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'
|
|
@ -1,4 +1,4 @@
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
from . import warnings
|
from . import warnings
|
||||||
|
|
||||||
# do this later -- for now need to transition modules to avoid using kompress directly (e.g. ZipPath)
|
# do this later -- for now need to transition modules to avoid using kompress directly (e.g. ZipPath)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Utils for mime/filetype handling
|
Utils for mime/filetype handling
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Helpers to prevent depending on pytest in runtime
|
Helpers to prevent depending on pytest in runtime
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import typing
|
import typing
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .common import assert_subpackage; assert_subpackage(__name__)
|
from .internal import assert_subpackage; assert_subpackage(__name__)
|
||||||
|
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
Loading…
Add table
Reference in a new issue