From b734dd0dcd72f5b985b3afce01e852c9c74e451a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 17 Feb 2022 19:16:09 +0100 Subject: [PATCH 1/2] fix: Catch alias resolution errors --- src/mkdocstrings_handlers/python/collector.py | 10 +++++++--- src/mkdocstrings_handlers/python/renderer.py | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mkdocstrings_handlers/python/collector.py b/src/mkdocstrings_handlers/python/collector.py index eb1879bd..ebddaaac 100644 --- a/src/mkdocstrings_handlers/python/collector.py +++ b/src/mkdocstrings_handlers/python/collector.py @@ -6,10 +6,12 @@ from __future__ import annotations from collections import ChainMap +from contextlib import suppress from griffe.agents.extensions import load_extensions from griffe.collections import LinesCollection, ModulesCollection from griffe.docstrings.parsers import Parser +from griffe.exceptions import AliasResolutionError from griffe.loader import GriffeLoader from mkdocstrings.handlers.base import BaseCollector, CollectionError, CollectorItem from mkdocstrings.loggers import get_logger @@ -85,8 +87,10 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: WPS2 except KeyError as error: # noqa: WPS440 raise CollectionError(f"{identifier} could not be found") from error - if not unknown_module and doc_object.docstring is not None: - doc_object.docstring.parser = parser - doc_object.docstring.parser_options = parser_options + if not unknown_module: + with suppress(AliasResolutionError): + if doc_object.docstring is not None: + doc_object.docstring.parser = parser + doc_object.docstring.parser_options = parser_options return doc_object diff --git a/src/mkdocstrings_handlers/python/renderer.py b/src/mkdocstrings_handlers/python/renderer.py index 77f367e4..93c91195 100644 --- a/src/mkdocstrings_handlers/python/renderer.py +++ b/src/mkdocstrings_handlers/python/renderer.py @@ -10,6 +10,7 @@ from typing import Any, Sequence from griffe.dataclasses import Alias, Object +from griffe.exceptions import AliasResolutionError from markdown import Markdown from markupsafe import Markup from mkdocstrings.extension import PluginError @@ -127,7 +128,10 @@ def render(self, data: CollectorItem, config: dict) -> str: # noqa: D102 (ignor ) def get_anchors(self, data: CollectorItem) -> list[str]: # noqa: D102 (ignore missing docstring) - return list({data.path, data.canonical_path, *data.aliases}) + try: + return list({data.path, data.canonical_path, *data.aliases}) + except AliasResolutionError: + return [data.path] def update_env(self, md: Markdown, config: dict) -> None: # noqa: D102 (ignore missing docstring) super().update_env(md, config) From 30bcf332a726af8166ddd1af1eb24cb6a555c637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 17 Feb 2022 19:16:33 +0100 Subject: [PATCH 2/2] chore: Prepare release 0.6.2 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 818971b2..2bba64b5 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.6.2](https://github.com/mkdocstrings/python/releases/tag/0.6.2) - 2022-02-17 + +[Compare with 0.6.1](https://github.com/mkdocstrings/python/compare/0.6.1...0.6.2) + +### Bug Fixes +- Catch alias resolution errors ([b734dd0](https://github.com/mkdocstrings/python/commit/b734dd0dcd72f5b985b3afce01e852c9c74e451a) by Timothée Mazzucotelli). + + ## [0.6.1](https://github.com/mkdocstrings/python/releases/tag/0.6.1) - 2022-02-17 [Compare with 0.6.0](https://github.com/mkdocstrings/python/compare/0.6.0...0.6.1)