Open
Description
When trying to document a project that's using SQLAlchemy, I get the following error message:
WARNING: error while formatting signature for module.DatabaseModel.created_at: Handler <function process_signature at 0x7f3faac891c0> for event 'autodoc-process-signature' threw an exception (exception: wrapper loop when unwrapping sqlalchemy.orm.mapped_column)
WARNING: error while formatting signature for module.DatabaseModel.updated_at: Handler <function process_signature at 0x7f3faac891c0> for event 'autodoc-process-signature' threw an exception (exception: wrapper loop when unwrapping sqlalchemy.orm.mapped_column)
Extension error (sphinx_autodoc_typehints):
Handler <function process_signature at 0x7fdf8b48d1c0> for event 'autodoc-process-signature' threw an exception (exception: wrapper loop when unwrapping sqlalchemy.orm.mapped_column)
I fear SQLalchemy is generally troublesome when it comes to autodoc, which is why it's added to autodoc_mock_imports
in my conf.py
. Would it be possible to do something similar with sphinx-autodoc-typehints?
A reproducible example:
from datetime import datetime
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from sqlalchemy.sql import func
class DatabaseModel(DeclarativeBase): # pylint: disable=too-few-public-methods
"""The declarative base for the ORM. Adds ``created_at`` and ``updated_at`` timestamp columns."""
created_at: Mapped[datetime] = mapped_column(server_default=func.now())
"""A ``datetime`` object, that is set on creation."""
updated_at: Mapped[datetime] = mapped_column(server_default=func.now(), server_onupdate=func.now())
"""A ``datetime`` object, that is updated on changes."""