Skip to content

Sphinx throws errors when using function in __getattr__ override #8917

@maehster

Description

@maehster

Describe the bug
When using anonymous functions in getattr sphinx will raise an error:

Handler <function record_typehints at 0x7f3626d18790> for event 'autodoc-process-signature' threw an exception (exception: 'function' object has no attribute 'get')

To Reproduce

def fun():
    pass

class Tmp:

    def __call__(self, name, content):
        print(name, content)

    def __getattr__(self, item):
        return fun

a = Tmp()
"""asdfasdf"""
cd docs && \
make clean && \
sphinx-apidoc --force -e -o ./source ../<package> && \
make html

Expected behavior
No error.

Environment info

  • Python version: [3.8.5]

Sphinx==3.4.3
sphinx-rtd-theme==0.5.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4

extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc', 'sphinx.ext.napoleon']

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions