ok, seems that import_dir is a bit saner
This commit is contained in:
parent
44aa062756
commit
0f80e9d5e6
3 changed files with 16 additions and 3 deletions
|
@ -9,6 +9,7 @@ import warnings
|
|||
# some helper functions
|
||||
PathIsh = Union[Path, str]
|
||||
|
||||
# TODO only used in tests? not sure if useful at all.
|
||||
# TODO port annotations to kython?..
|
||||
def import_file(p: PathIsh, name: Optional[str]=None) -> types.ModuleType:
|
||||
p = Path(p)
|
||||
|
@ -33,6 +34,11 @@ def import_from(path: PathIsh, name: str) -> types.ModuleType:
|
|||
sys.path.remove(path)
|
||||
|
||||
|
||||
def import_dir(path: PathIsh) -> types.ModuleType:
|
||||
p = Path(path)
|
||||
return import_from(p.parent, p.name)
|
||||
|
||||
|
||||
T = TypeVar('T')
|
||||
K = TypeVar('K')
|
||||
V = TypeVar('V')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue