← All challenges
easysphinx-doc/sphinx · v3.1

overescaped trailing underscore on attribute with napoleon

Try this bug with AI

Fix it in the original repo with an AI agent and get feedback on how you worked.

2 free rounds each week

Round mode
  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to135 XP
Sign up or sign in to start

Read the sample report

From a simulated Django round

You changed code before reproducing the bug.

Run the failing test before the first edit, so you know the failure you are fixing and can tell when it is gone.

Problem statement

Describe the bug
Attribute name hello_ shows up as hello\_ in the html (visible backslash) with napoleon.

To Reproduce
Steps to reproduce the behavior:

empty __init__.py
a.py contains

python
class A:
    """
    Attributes
    ----------
    hello_: int
        hi
    """
    pass

run sphinx-quickstart
add 'sphinx.ext.autodoc', 'sphinx.ext.napoleon' to extensions in conf.py.
add .. autoclass:: a.A to index.rst
PYTHONPATH=. make clean html
open _build/html/index.html in web browser and see the ugly backslash.

Expected behavior
No backslash, a similar output to what I get for

rst
    .. attribute:: hello_
        :type: int

        hi

(the type shows up differently as well, but that's not the point here)
Older versions like 2.4.3 look ok to me.

Environment info

  • OS: Linux debian testing
  • Python version: 3.8.3
  • Sphinx version: 3.0.4
  • Sphinx extensions: sphinx.ext.autodoc, sphinx.ext.napoleon
  • Extra tools:
The environment starts at commit c087d717f6ed (sphinx-doc/sphinx 3.1), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.