From 6ba3e0461647c2c76d0fd68889d37bbada686259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Sat, 9 Sep 2023 19:17:19 +0200 Subject: [PATCH] fix: Fix warnings for docstrings in builtin modules --- src/griffe/docstrings/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/griffe/docstrings/utils.py b/src/griffe/docstrings/utils.py index ac3e9463..e2c63ce2 100644 --- a/src/griffe/docstrings/utils.py +++ b/src/griffe/docstrings/utils.py @@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Protocol from griffe.agents.nodes import safe_get_annotation +from griffe.exceptions import BuiltinModuleError from griffe.logger import LogLevel, get_logger if TYPE_CHECKING: @@ -42,6 +43,8 @@ def warn(docstring: Docstring, offset: int, message: str, log_level: LogLevel = prefix = docstring.parent.relative_filepath # type: ignore[union-attr] except (AttributeError, ValueError): prefix = "" + except BuiltinModuleError: + prefix = f"" log = getattr(logger, log_level.value) log(f"{prefix}:{(docstring.lineno or 0)+offset}: {message}")