diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b4839fd..0ea7668c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.21.2](https://github.com/mkdocstrings/mkdocstrings/releases/tag/0.21.2) - 2023-04-06 + +[Compare with 0.21.1](https://github.com/mkdocstrings/mkdocstrings/compare/0.21.1...0.21.2) + +### Bug Fixes + +- Fix regression with LRU cached method ([85efbd2](https://github.com/mkdocstrings/mkdocstrings/commit/85efbd285d4c8977755bda1c36220b241a9e1502) by Timothée Mazzucotelli). [Issue #549](https://github.com/mkdocstrings/mkdocstrings/issues/549) + ## [0.21.1](https://github.com/mkdocstrings/mkdocstrings/releases/tag/0.21.1) - 2023-04-05 [Compare with 0.21.0](https://github.com/mkdocstrings/mkdocstrings/compare/0.21.0...0.21.1) diff --git a/src/mkdocstrings/plugin.py b/src/mkdocstrings/plugin.py index a35309c8..5233cf4f 100644 --- a/src/mkdocstrings/plugin.py +++ b/src/mkdocstrings/plugin.py @@ -231,7 +231,7 @@ def on_config(self, config: Config, **kwargs: Any) -> Config: # noqa: ARG002 inv_loader = futures.ThreadPoolExecutor(4) for handler_name, import_item in to_import: future = inv_loader.submit( - self._load_inventory, + self._load_inventory, # type: ignore[misc] self.get_handler(handler_name).load_inventory, **import_item, ) @@ -330,9 +330,9 @@ def get_handler(self, handler_name: str) -> BaseHandler: return self.handlers.get_handler(handler_name) @classmethod - @functools.lru_cache(maxsize=None) # lru_cache does not allow mutable arguments such lists, but that is what we load from YAML config. @list_to_tuple + @functools.lru_cache(maxsize=None) def _load_inventory(cls, loader: InventoryLoaderType, url: str, **kwargs: Any) -> Mapping[str, str]: """Download and process inventory files using a handler. diff --git a/tests/test_inventory.py b/tests/test_inventory.py index ecbb3cd2..ce707296 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -5,6 +5,7 @@ import sys from io import BytesIO from os.path import join +from typing import TYPE_CHECKING import pytest from mkdocs.commands.build import build @@ -12,6 +13,8 @@ from mkdocstrings.inventory import Inventory, InventoryItem +if TYPE_CHECKING: + from mkdocstrings.plugin import MkdocstringsPlugin sphinx = pytest.importorskip("sphinx.util.inventory", reason="Sphinx is not installed") @@ -55,3 +58,12 @@ def test_sphinx_load_mkdocstrings_inventory_file() -> None: for item in own_inv.values(): assert item.name in sphinx_inv[f"{item.domain}:{item.role}"] + + +def test_load_inventory(plugin: MkdocstringsPlugin) -> None: + """Test the plugin inventory loading method. + + Parameters: + plugin: A mkdocstrings plugin instance. + """ + plugin._load_inventory(loader=lambda *args, **kwargs: (), url="https://example.com", domains=["a", "b"]) # type: ignore[misc,arg-type]