From d46e86c6766a3c1bb83b2016f1d830298ceeb727 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Wed, 4 Oct 2023 22:08:01 -0700 Subject: [PATCH] return None when the module actually doesn't exist --- nwb_linkml/src/nwb_linkml/providers/schema.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nwb_linkml/src/nwb_linkml/providers/schema.py b/nwb_linkml/src/nwb_linkml/providers/schema.py index 4e48d6e..a08ee35 100644 --- a/nwb_linkml/src/nwb_linkml/providers/schema.py +++ b/nwb_linkml/src/nwb_linkml/providers/schema.py @@ -801,12 +801,16 @@ class EctopicModelFinder(MetaPathFinder): # get submodule beneath model stem submod = fullname.replace(self.MODEL_STEM, '').lstrip('.') base_path = Path(self.path, *submod.split('.')) + # switch if we're asked for a package or a module mod_path = Path(str(base_path) + '.py') + pkg_path = base_path / '__init__.py' if mod_path.exists(): import_path = mod_path + elif pkg_path.exists(): + import_path = pkg_path else: - import_path = base_path / '__init__.py' + return None spec = importlib.util.spec_from_file_location(fullname, import_path) return spec