sphinx-doc / sphinx-doc/sphinx

test_autodoc_type_aliases failing on 3.12.4

Open
#12,430 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

After upgrading to Python 3.12.4 the test_autodoc_type_aliases test fails on Sphinx 3.7.3.

sphinx> __________________________ test_autodoc_type_aliases ___________________________
sphinx> [gw26] linux -- Python 3.12.4 /nix/store/w23yb3ajva7rq12cwl2ax95fd6y530p9-python3-3.12.4/bin/python3.12
sphinx> 
sphinx> app = <SphinxTestApp buildername='text'>
sphinx> 
sphinx>     @pytest.mark.sphinx('text', testroot='ext-autodoc')
sphinx>     def test_autodoc_type_aliases(app):
sphinx>         # default
sphinx>         options = {"members": None}
sphinx>         actual = do_autodoc(app, 'module', 'target.autodoc_type_aliases', options)
sphinx> >       assert list(actual) == [
sphinx>             '',
sphinx>             '.. py:module:: target.autodoc_type_aliases',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:class:: Foo()',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '   .. py:attribute:: Foo.attr1',
sphinx>             '      :module: target.autodoc_type_aliases',
sphinx>             '      :type: int',
sphinx>             '',
sphinx>             '      docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '   .. py:attribute:: Foo.attr2',
sphinx>             '      :module: target.autodoc_type_aliases',
sphinx>             '      :type: int',
sphinx>             '',
sphinx>             '      docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:function:: mult(x: int, y: int) -> int',
sphinx>             '                 mult(x: float, y: float) -> float',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:function:: read(r: ~_io.BytesIO) -> ~_io.StringIO',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:function:: sum(x: int, y: int) -> int',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:data:: variable',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '   :type: int',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:data:: variable2',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '   :type: int',
sphinx>             '   :value: None',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>             '',
sphinx>             '.. py:data:: variable3',
sphinx>             '   :module: target.autodoc_type_aliases',
sphinx>             '   :type: int | None',
sphinx>             '',
sphinx>             '   docstring',
sphinx>             '',
sphinx>         ]
sphinx> E       AssertionError: assert ['', '.. py:module:: target.autodoc_type_aliases', '', '', '.. py:class:: Foo()', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '   .. py:attribute:: Foo.attr1', '      :module: target.autodoc_type_aliases', '      :type: int', '', '      docstring', '', '', '   .. py:attribute:: Foo.attr2', '      :module: target.autodoc_type_aliases', '      :type: int', '', '      docstring', '', '', '.. py:function:: mult(x: myint, y: myint) -> myint', '                 mult(x: float, y: float) -> float', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '.. py:function:: read(r: ~_io.BytesIO) -> ~_io.StringIO', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '.. py:function:: sum(x: int, y: int) -> int', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '.. py:data:: variable', '   :module: target.autodoc_type_aliases', '   :type: int', '', '   docstring', '', '', '.. py:data:: variable2', '   :module: target.autodoc_type_aliases', '   :type: int', '   :value: None', '', '   docstring', '', '', '.. py:data:: variable3', '   :module: target.autodoc_type_aliases', '   :type: int | None', '', '   docstring', ''] == ['', '.. py:module:: target.autodoc_type_aliases', '', '', '.. py:class:: Foo()', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '   .. py:attribute:: Foo.attr1', '      :module: target.autodoc_type_aliases', '      :type: int', '', '      docstring', '', '', '   .. py:attribute:: Foo.attr2', '      :module: target.autodoc_type_aliases', '      :type: int', '', '      docstring', '', '', '.. py:function:: mult(x: int, y: int) -> int', '                 mult(x: float, y: float) -> float', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '.. py:function:: read(r: ~_io.BytesIO) -> ~_io.StringIO', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '.. py:function:: sum(x: int, y: int) -> int', '   :module: target.autodoc_type_aliases', '', '   docstring', '', '', '.. py:data:: variable', '   :module: target.autodoc_type_aliases', '   :type: int', '', '   docstring', '', '', '.. py:data:: variable2', '   :module: target.autodoc_type_aliases', '   :type: int', '   :value: None', '', '   docstring', '', '', '.. py:data:: variable3', '   :module: target.autodoc_type_aliases', '   :type: int | None', '', '   docstring', '']
sphinx> E         
sphinx> E         At index 24 diff: '.. py:function:: mult(x: myint, y: myint) -> myint' != '.. py:function:: mult(x: int, y: int) -> int'
sphinx> E         
sphinx> E         Full diff:
sphinx> E           [
sphinx> E               '',
sphinx> E               '.. py:module:: target.autodoc_type_aliases',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '.. py:class:: Foo()',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '   .. py:attribute:: Foo.attr1',
sphinx> E               '      :module: target.autodoc_type_aliases',
sphinx> E               '      :type: int',
sphinx> E               '',
sphinx> E               '      docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '   .. py:attribute:: Foo.attr2',
sphinx> E               '      :module: target.autodoc_type_aliases',
sphinx> E               '      :type: int',
sphinx> E               '',
sphinx> E               '      docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E         -     '.. py:function:: mult(x: int, y: int) -> int',
sphinx> E         +     '.. py:function:: mult(x: myint, y: myint) -> myint',
sphinx> E         ?                               ++        ++        ++
sphinx> E               '                 mult(x: float, y: float) -> float',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '.. py:function:: read(r: ~_io.BytesIO) -> ~_io.StringIO',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '.. py:function:: sum(x: int, y: int) -> int',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '.. py:data:: variable',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '   :type: int',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '.. py:data:: variable2',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '   :type: int',
sphinx> E               '   :value: None',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E               '',
sphinx> E               '.. py:data:: variable3',
sphinx> E               '   :module: target.autodoc_type_aliases',
sphinx> E               '   :type: int | None',
sphinx> E               '',
sphinx> E               '   docstring',
sphinx> E               '',
sphinx> E           ]
sphinx> 
sphinx> tests/test_extensions/test_ext_autodoc_configs.py:1258: AssertionError
sphinx> --------------------------- Captured stdout teardown ---------------------------
sphinx> # testroot: root
sphinx> # builder: text
sphinx> # srcdir: /build/pytest-of-nixbld/pytest-0/popen-gw26/ext-autodoc
sphinx> # outdir: /build/pytest-of-nixbld/pytest-0/popen-gw26/ext-autodoc/_build/text
sphinx> # status: 
sphinx> Running Sphinx v7.3.7
sphinx> 
sphinx> # warning: 
sphinx> 
How to Reproduce
  • Update to Python 3.12.4
  • Run the test suite
Environment Information
Platform:              linux; (Linux-6.8.9-x86_64-with-glibc2.39)
Python version:        3.12.4 (main, Jun  6 2024, 18:26:44) [GCC 13.3.0])
Python implementation: CPython
Sphinx version:        7.3.7
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0
Sphinx extensions

Just the required ones:

sphinxcontrib-applehelp
sphinxcontrib-devhelp
sphinxcontrib-htmlhelp
sphinxcontrib-jsmath
sphinxcontrib-qthelp
sphinxcontrib-serializinghtml
sphinxcontrib-websupport
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

Start with tests/test_extensions/test_ext_autodoc_configs.py:1258 and the ext-autodoc testroot used by test_autodoc_type_aliases. Run that test under Python 3.12.4 and inspect why the rendered mult signature keeps the alias myint instead of int. Done means the expected output is restored and the test passes on the affected Python version.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.