Skip to content

Commit

Permalink
fix: Fix warnings for docstrings in builtin modules
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Sep 9, 2023
1 parent 066a4a7 commit 6ba3e04
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/griffe/docstrings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = "<module>"
except BuiltinModuleError:
prefix = f"<module: {docstring.parent.module.name}>"
log = getattr(logger, log_level.value)
log(f"{prefix}:{(docstring.lineno or 0)+offset}: {message}")

Expand Down

0 comments on commit 6ba3e04

Please sign in to comment.