Render TypeVars as text in restify#14504
Open
gaborbernat wants to merge 1 commit into
Open
Conversation
7c32d9d to
fa3d857
Compare
restify() emitted a py:obj cross-reference for a TypeVar. A bare TypeVar
is usually not a documentable target, so with show-inheritance a class
deriving from Generic[_T] (with an undocumented type variable) produced a
nitpicky/-W failure:
py:obj reference target not found: mod._T [ref.obj]
Render a TypeVar as its ``TypeVar(name, ...)`` definition instead: the
class links to typing, and the name links only when it is itself
documented (or available via intersphinx), otherwise falling back to text
via a new missing-reference handler in the Python domain.
Closes sphinx-doc#14502
fa3d857 to
bcb6c31
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14502.
restify()emits a:py:obj:cross-reference for aTypeVar, whereasstringify_annotation()renders TypeVars as plain text. ATypeVaris not a documentable target, so that reference is never resolvable. Withshow-inheritance, documenting a class that derives fromGeneric[_T](where_Tis an undocumented, e.g. private, type variable) therefore fails anitpicky/-Wbuild:This renders TypeVars by name in
restify()too, making it consistent withstringify_annotation()and removing the dangling reference. The existingtest_restify_type_hints_typevarsassertions are updated to the text rendering, and a regression note is added toCHANGES.rst.Minimal reproducer (passes after this change):