Skip to content

Comments

swev-id: sphinx-doc__sphinx-8459 - honor autodoc type aliases#57

Open
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-8459from
fix/autodoc-alias-description-8459
Open

swev-id: sphinx-doc__sphinx-8459 - honor autodoc type aliases#57
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-8459from
fix/autodoc-alias-description-8459

Conversation

@casey-brooks
Copy link

Summary

  • apply autodoc_type_aliases when recording description-based type hints
  • add regression coverage that builds a project with autodoc_typehints='description' and asserts alias names reach the rendered Parameters/Return sections

Reproduction

  1. Checkout sphinx-doc__sphinx-8459 and create a virtualenv.
  2. pip install -e '.[test]' followed by the branch pins (pip install 'Jinja2<3.1' 'MarkupSafe<2.1' 'docutils>=0.16,<0.17' roman 'alabaster==0.7.12' 'Pygments==2.17.2' 'sphinxcontrib-applehelp==1.0.4' 'sphinxcontrib-devhelp==1.0.2' 'sphinxcontrib-htmlhelp==1.0.3' 'sphinxcontrib-qthelp==1.0.3' 'sphinxcontrib-serializinghtml==1.1.4').
  3. PYTHONPATH=$(pwd) pytest tests/test_ext_autodoc_configs.py::test_autodoc_typehints_description_respects_aliases -q

Observed Failure

E       AssertionError: assert 'Parameters:\n      **value** (*AliasName*) --' in 'aliaspkg.alias_description.use_alias(value)\n\n   Return the provided value unchanged.\n\n   Parameters:\n      **value** (*aliaspkg.alias_description.AliasTarget*) --\n\n   Return type:\n      aliaspkg.alias_description.AliasTarget\n'

Testing

  • flake8 tests/test_ext_autodoc_configs.py sphinx/ext/autodoc/typehints.py
  • PYTHONPATH=$(pwd) pytest tests/test_ext_autodoc_configs.py::test_autodoc_typehints_description -q
  • PYTHONPATH=$(pwd) pytest tests/test_ext_autodoc_configs.py::test_autodoc_typehints_description_respects_aliases -q

@casey-brooks casey-brooks requested a review from a team December 26, 2025 17:32
Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Applying autodoc_type_aliases inside record_typehints keeps the description-mode annotations aligned with the rest of autodoc, and the new regression test exercises alias rendering end-to-end. Thanks for adding coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants