Skip to content

Sphinx 4.3 raises an 'autodoc-before-process-signature' error with functools.partial #9844

@bhrutledge

Description

@bhrutledge

Describe the bug

When using autodoc_preserve_defaults and a module that defines a partial, I get the following warning from sphinx-build:

WARNING: error while formatting arguments for example_package.example_partial: Handler <function update_defvalue at 0x102f24310> for event 'autodoc-before-process-signature' threw an exception (exception: module, class, method, function, traceback, frame, or code object was expected, got partial).

I don't get this warning in Sphinx 4.2.0.

How to Reproduce

I re-used an example repo from an earlier issue: https://github.com/bhrutledge/sphinx-requests-typehints, which includes setup instructions. The rendered docs show the current behavior with Sphinx 4.2.0.

On that repo, I created a PR with Sphinx 4.3.0, where the rendered docs show the missing partial signature.

I also opened PR with Sphinx 4.3.0 but not autodoc_preserve_defaults. The rendered docs show the restored partial signature, but the default arguments are less useful.

Expected behavior

I expect Sphinx 4.3.0 to generate the same documentation as 4.2.0 without errors.

Your project

https://github.com/bhrutledge/sphinx-requests-typehints

Screenshots

No response

OS

Mac

Python version

3.9.7

Sphinx version

4.3.0

Sphinx extensions

sphinx.ext.autodoc

Extra tools

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions