[Python] The SQLAlchemy @hybrid_property decorator creates an exception in Sphinx autodoc and...

Discussão em 'Python' iniciado por Stack, Agosto 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have a SQLAlchemy @hybrid_property like this:

    @hybrid_property
    def number_of_lightnings(self) -> int:
    """
    Blah, blah, blah....


    when I generate the docs with Sphinx I get the following exception:

    WARNING: autodoc: failed to determine src.data_model.thunderstorm.Thunderstorm.number_of_lightnings (<sqlalchemy.ext.hybrid.hybrid_property object at 0x7fba987f0d90>) to be documented, the following exception was raised:
    Handler <function _skip_member at 0x7fbabb6ed120> for event 'autodoc-skip-member' threw an exception (exception: object of type 'InstrumentedAttribute' has no len()) [autodoc]


    the property never gets documented. Adding my custom handler

    def maybe_skip_member(app, what, name, obj, skip, options):
    print(name)
    return True

    def setup(app):
    app.connect('autodoc-skip-member', maybe_skip_member)


    does not solve the problem because the name number_of_lightnings never appears. I suppose due to the raised exception.

    Any hints to solve this?

    Continue reading...

Compartilhe esta Página