Skip to content

Incorrect parsing of class init annotations #14159

@alexfikl

Description

@alexfikl

Describe the bug

Sphinx 9.0.4 seems to parse arguments with type annotations incorrectly. I have the following class

Image

and get the error

<unknown>:1: WARNING: py:class reference target not found: list[tuple[float [ref.class]

This looks like it is getting confused by the comma in the tuple when parsing the arguments in there, but I have not looked into it very carefully. The same annotation for the class member seems to work just fine.

This seems to be related to the fact that there's a <factory> default in there.

How to Reproduce

An MRE can be found here: sphinx-bug-mre.zip. I am generating the documentation using

cd docs
python -m sphinx -M html . _build -W -n --keep-going

in a virtual environment created using mkvirtualenv sphinx-bug.

Environment Information

Platform:              linux; (Linux-6.17.9-arch1-1-x86_64-with-glibc2.42)
Python version:        3.13.7 (main, Aug 15 2025, 12:34:02) [GCC 15.2.1 20250813])
Python implementation: CPython
Sphinx version:        9.0.4
Docutils version:      0.22.3
Jinja2 version:        3.1.6
Pygments version:      2.19.2

Sphinx extensions

Extensions: ["autodoc", "intersphinx"]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions