Skip to content

mangle_docstrings triggers RemovedInSphinx11Warning via deprecated mapping interface #679

Description

@gaborbernat

Description

mangle_docstrings at numpydoc.py:191 calls cfg.update(options or {}) where options is a _AutoDocumenterOptions instance passed by Sphinx's autodoc-process-docstring event.

Since Sphinx 10, _AutoDocumenterOptions emits RemovedInSphinx11Warning when its mapping interface (__iter__, __getitem__, etc.) is used. dict.update() triggers __iter__ on the options object, producing:

The mapping interface for autodoc options objects is deprecated,
and will be removed in Sphinx 11. Use attribute access instead.

Suggested fix

Replace the try/except block:

# current
try:
    cfg.update(options or {})
except TypeError:
    cfg.update(options.__dict__ or {})

with:

if options is not None:
    cfg.update(vars(options))

vars(options) returns the instance __dict__ directly, avoiding the deprecated mapping interface entirely. This works because _AutoDocumenterOptions.__init__ stores all attributes via vars(self).update(kwargs).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions