Skip to content

Accommodate Sphinx option by changing docstring return type of "integer" to "int". #100989

Closed
@timobrembeck

Description

@timobrembeck

Bug report

When collections.deque is subclassed and the resulting class is documented with Sphinx using the option :inherited-members:, the following error appears:

WARNING: py:class reference target not found: integer -- return number of occurrences of value

I assume this is because the PyDoc_STRVAR docstring of the C-implementation is not compliant to PEP-7 as required in PyDoc_STRVAR:

PyDoc_STRVAR(count_doc,
"D.count(value) -> integer -- return number of occurrences of value");

And everything after -> is interpreted as type hint.

This can be reproduced with e.g. a python module sub_deque.py:

class SubDeque(deque):
    pass

and a documenation file docs/src/sub_deque.rst:

.. automodule:: sub_deque
   :inherited-members:

which is then built with Sphinx: sphinx-build -W docs/src docs/dist.

I'd be happy to provide a patch for this myself if you feel this issue should be fixed.

Your environment

  • CPython versions tested on: 3.7 - 3.11
  • Operating system and architecture: Arch Linux & Ubuntu

Linked PRs

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dirextension-modulesC modules in the Modules dir

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions