Skip to content

Commit 0dac001

Browse files
authored
Merge pull request #181 from opsmill/pog-sys-path
Fix import_root in case a Path object was submitted
2 parents da1d89a + 1953714 commit 0dac001

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

changelog/+513f19bc.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Convert import_root to a string if it was submitted as a Path object to ensure that anything added to sys.path is a string

infrahub_sdk/_importer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def import_module(
2222
if import_root and relative_path:
2323
file_on_disk = Path(import_root, relative_path, module_path.name)
2424

25+
# This is a temporary workaround for to account for issues if "import_root" is a Path instead of a str
26+
# Later we should rework this so that import_root and relative_path are all Path objects. Here we must
27+
# ensure that anything we add to sys.path is a string and not a Path or PosixPath object.
28+
import_root = str(import_root)
2529
if import_root not in sys.path:
2630
sys.path.append(import_root)
2731

0 commit comments

Comments
 (0)