sphinx-doc / sphinx-doc/sphinx

autodoc loses first parameter of staticmethod when global is pulled by autofunction

Open
#12,835 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

extensions:autodoc type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Similar to #4769 and #9342, in this specific circumstance, the first argument of staticmethod is lost:

How to Reproduce

ops/__init__.py

class Example:
    @staticmethod
    def __call__(foo: int, bar: str) -> float:
        return 42.

example = Example()
"""
Some description
"""

docs/index.rst

ops module
==========

.. automodule:: ops

.. autofunction:: ops.example

Generates this doc:

ops.example(bar: str) → float
Some description

Environment Information
Sphinx 8.0.2
Sphinx extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with ops/init.py and docs/index.rst using Sphinx 8.0.2, then trace the autodoc and autofunction handling for the staticmethod example. Done means the generated ops.example signature retains both foo and bar while preserving the documented return type and description.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.