← All challenges
mediumsphinx-doc/sphinx · v3.5

autodoc isn't able to resolve struct.Struct type annotations

docstoolingbase 332d80ba84
Mode

60 minutes, the full token budget.

  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to210 XP

Opens VS Code with an AI agent in a new tab. Prompts, tokens, tool calls and test runs are recorded and scored.

Problem statement

Describe the bug
If struct.Struct is declared in any type annotations, I get class reference target not found: Struct

To Reproduce
Simple index.rst

Hello World
===========

code docs
=========

.. automodule:: helloworld.helloworld

Simple helloworld.py

import struct
import pathlib

def consume_struct(_: struct.Struct) -> None:
    pass

def make_struct() -> struct.Struct:
    mystruct = struct.Struct('HH')
    return mystruct

def make_path() -> pathlib.Path:
    return pathlib.Path()

Command line:

python3 -m sphinx -b html docs/ doc-out -nvWT

Expected behavior
If you comment out the 2 functions that have Struct type annotations, you'll see that pathlib.Path resolves fine and shows up in the resulting documentation. I'd expect that Struct would also resolve correctly.

Your project
n/a

Screenshots
n/a

Environment info

  • OS: Ubuntu 18.04, 20.04
  • Python version: 3.8.2
  • Sphinx version: 3.2.1
  • Sphinx extensions: 'sphinx.ext.autodoc',
          'sphinx.ext.autosectionlabel',
          'sphinx.ext.intersphinx',
          'sphinx.ext.doctest',
          'sphinx.ext.todo'
  • Extra tools:

Additional context

  • [e.g. URL or Ticket]
The environment starts at commit 332d80ba8433 (sphinx-doc/sphinx 3.5), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.