Skip to content

Commit 492759c

Browse files
committed
Update with changes from local repo (#278)
- add pytest to test in pyproject.toml
1 parent cc54168 commit 492759c

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

mkdocs_macros/plugin.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,12 @@ def _load_modules(self):
583583
# local module (file or dir)
584584
local_module_name = self.config['module_name']
585585
debug("Project dir '%s'" % self.project_dir)
586-
module = import_local_module(self.project_dir, local_module_name)
587-
if module:
586+
try:
587+
module = import_local_module(self.project_dir, local_module_name)
588588
trace("Found local Python module '%s' in:" % local_module_name,
589589
self.project_dir)
590590
self._load_module(module, local_module_name)
591-
592-
else:
591+
except ImportError:
593592
if local_module_name == DEFAULT_MODULE_NAME:
594593
# do not do anything if there is no main module
595594
trace("No default module `%s` found" % DEFAULT_MODULE_NAME)

mkdocs_macros/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ def import_local_module(project_dir, module_name):
203203
module_name = os.path.basename(module_name)
204204
return importlib.import_module(module_name, package='main')
205205
else:
206-
# This is made necessary by the logic
207-
return None
206+
raise ImportError(f"Cannot import module '{module_name}'")
208207

209208

210209
# ------------------------------------------

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ packages = { find = { exclude = ["*.tests"] } }
3838

3939
[project.optional-dependencies]
4040
test = [
41+
"pytest",
4142
"mkdocs-include-markdown-plugin",
4243
"mkdocs-macros-test",
4344
"mkdocs-material>=6.2",

0 commit comments

Comments
 (0)