dirname cannot be falsey

This commit is contained in:
Matthew Donoughe 2022-10-21 20:21:08 -04:00
parent 607eece72a
commit 69d1b8fc08
No known key found for this signature in database
GPG Key ID: 838812402CA8C19D
1 changed files with 2 additions and 4 deletions

View File

@ -15,13 +15,11 @@ def _import_file(filepath: Union[str, PathLike]) -> ModuleType:
if abspath.suffix not in ('.py', '.pyw'):
raise ValueError(f"Not a Python source file: {abspath}")
dirname = str(abspath.parent)
if dirname:
sys.path = [dirname] + sys.path
sys.path = [dirname] + sys.path
try:
module = import_module(abspath.stem)
finally:
if dirname:
sys.path.pop(0)
sys.path.pop(0)
return module