Open
Description
Summary
If a PEP224 style docstring is used for a global variable of type Callable
, that is assigned a function re-exported from another package, the custom docstring is not used, and instead the docstring of the original function is used instead.
I found one way to work around this, which is to overwrite the original function's docstring using get_logger.__doc__ = "Custom docstring"
, however it seems to me that this perhaps shouldn't be necessary, and that the below might be a bug?
Steps to Reproduce
mkdir -p testcase/mymodule && cd testcase
echo -e 'from typing import Callable\nimport structlog\n\n__all__ = ["get_logger"]\n\nget_logger: Callable[..., structlog.stdlib.BoundLogger] = structlog.stdlib.get_logger\n"""Custom docstring"""' > mymodule/__init__.py
pip install structlog pdoc3
pdoc3 mymodule
This file written above, expanded here to make it easier to read:
from typing import Callable
import structlog
__all__ = ["get_logger"]
get_logger: Callable[..., structlog.stdlib.BoundLogger] = structlog.stdlib.get_logger
"""Custom docstring"""
Expected Behavior
$ pdoc3 mymodule
Module mymodule
===============
Functions
---------
`get_logger(*args: Any, **initial_values: Any) ‑> structlog.stdlib.BoundLogger`
: Custom docstring
Actual Behavior
$ pdoc3 mymodule
Module mymodule
===============
Functions
---------
`get_logger(*args: Any, **initial_values: Any) ‑> structlog.stdlib.BoundLogger`
: Only calls `structlog.get_logger`, but has the correct type hints.
.. warning::
Does **not** check whether -- or ensure that -- you've configured
*structlog* for standard library :mod:`logging`!
See :doc:`standard-library` for details.
.. versionadded:: 20.2.0
Additional info
- pdoc version: 0.10.0
- Python version: 3.11.1