Skip to content

bug: Doc in module attributes are not picked up #12

@willemkokke

Description

@willemkokke

Description of the bug

griffe-typingdoc seems to not work on module attributes.

"""Module to test griffe-typingdoc."""

from typing import Annotated

from pydantic import StringConstraints
from typing_extensions import Doc

ChecksumString = Annotated[
    str, Doc("A sha256 checksum."), StringConstraints(pattern="^[a-fA-F0-9]{64}$")
]

ChecksumString2 = Annotated[str, StringConstraints(pattern="^[a-fA-F0-9]{64}$")]
"""Alternative checksum string."""

NormalString = Annotated[str, Doc("A normal string.")]


def hi(to: Annotated[str, Doc("Who to say hi to")]) -> None:
    """Say hi to someone."""
    print(f"Hi {to}!")


def hi_no_docstring(to: Annotated[str, Doc("Who to say hi to")]) -> None:
    print(f"Hi {to}!")

To Reproduce

 ```
 git clone https://github.com/willemkokke/griffe-typingdoc-repro/
 cd griffe-typingdoc-repro
 uv run mkdocs serve --verbose --open
 ```

Expected behavior

The generated docs should have a description for ChecksumString and NormalString.

Environment information

  • System: macOS-15.2-arm64-arm-64bit
  • Python: cpython 3.11.11 (/Users/willem/Documents/Repositories/griffe-typingdoc-repro/.venv/bin/python3)
  • Environment variables:
  • Installed packages:
    • griffe-typingdoc v0.2.7

Additional context

Only learned about pep 727 yesterday when fine-tuning my mkdocstrings configuration. I might be misunderstanding it completely!

I've also tried this with unwrap_annotated: false with identical results.

Urgency is low, the alternative of just using a docstring after the module attribute works fine.

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions