Skip to content

Fix extra () after NewType in rendered output#608

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
worksbyfriday:fix-newtype-extra-parens
Feb 17, 2026
Merged

Fix extra () after NewType in rendered output#608
gaborbernat merged 2 commits into
tox-dev:mainfrom
worksbyfriday:fix-newtype-extra-parens

Conversation

@worksbyfriday

Copy link
Copy Markdown
Contributor

Summary

Fixes the extra () after NewType in rendered HTML output. The :py:class: Sphinx role appends parentheses to indicate callability, producing NewType()(W, str) instead of NewType(W, str).

Fixes #216

Changes

  • Changed Sphinx role for NewType from :py:class: to :py:obj: in format_annotation()
  • Updated test expectation to match the new role

Why :py:obj:?

  • :py:class: adds () in HTML output (Sphinx's add_function_parentheses behavior)
  • :py:obj: is a generic cross-reference that doesn't add parentheses
  • Text output is unchanged — both roles produce quoted cross-references in text mode

Test plan

  • All 344 tests pass
  • format_annotation unit test updated for new role
  • Integration tests unchanged (text output format is identical)

Change the Sphinx role for NewType from :py:class: to :py:obj: to
prevent Sphinx from appending () after the type name in HTML output.
The :py:class: role adds parentheses to indicate callability, which
produces "NewType()(name, type)" instead of "NewType(name, type)".

Fixes tox-dev#216
@gaborbernat
gaborbernat merged commit dc92a64 into tox-dev:main Feb 17, 2026
8 checks passed
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.

Extra () after NewType

2 participants