From f725896ded0c0b03e08ce4a666f7e3d60b5168d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar=20Rubio?= Date: Thu, 21 Nov 2024 06:18:24 +0100 Subject: [PATCH] Fix error checking dependency --- pyproject.toml | 2 +- src/mkdocs_include_markdown_plugin/cache.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2293a2d..c00deb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mkdocs-include-markdown-plugin" -version = "7.1.0" +version = "7.1.1" description = "Mkdocs Markdown includer plugin." readme = "README.md" license = "Apache-2.0" diff --git a/src/mkdocs_include_markdown_plugin/cache.py b/src/mkdocs_include_markdown_plugin/cache.py index 053e764..137c3f5 100644 --- a/src/mkdocs_include_markdown_plugin/cache.py +++ b/src/mkdocs_include_markdown_plugin/cache.py @@ -9,12 +9,7 @@ from importlib.util import find_spec -try: - platformdirs_spec = find_spec('platformdirs') -except ImportError: # pragma: no cover - CACHE_AVAILABLE = False -else: - CACHE_AVAILABLE = True +CACHE_AVAILABLE = find_spec('platformdirs') is not None class Cache: @@ -80,7 +75,11 @@ def get_cache_directory() -> str | None: if not CACHE_AVAILABLE: return None - from platformdirs import user_data_dir + try: + from platformdirs import user_data_dir + except ImportError: + return None + cache_dir = user_data_dir('mkdocs-include-markdown-plugin') os.makedirs(cache_dir, exist_ok=True)