mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #9418: Fix missing bracket for empty Callable annotations.
This commit is contained in:
parent
f9644cb080
commit
a67105974f
3
CHANGES
3
CHANGES
@ -16,6 +16,9 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #9418: a Callable annotation with no parameters (e.g. Callable[[], None]) will
|
||||||
|
be rendered with a bracket missing (Callable[], None])
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -129,10 +129,14 @@ def _parse_annotation(annotation: str, env: BuildEnvironment = None) -> List[Nod
|
|||||||
return unparse(node.value)
|
return unparse(node.value)
|
||||||
elif isinstance(node, ast.List):
|
elif isinstance(node, ast.List):
|
||||||
result = [addnodes.desc_sig_punctuation('', '[')]
|
result = [addnodes.desc_sig_punctuation('', '[')]
|
||||||
for elem in node.elts:
|
if node.elts:
|
||||||
result.extend(unparse(elem))
|
# check if there are elements in node.elts to only pop the
|
||||||
result.append(addnodes.desc_sig_punctuation('', ', '))
|
# last element of result if the for-loop was run at least
|
||||||
result.pop()
|
# once
|
||||||
|
for elem in node.elts:
|
||||||
|
result.extend(unparse(elem))
|
||||||
|
result.append(addnodes.desc_sig_punctuation('', ', '))
|
||||||
|
result.pop()
|
||||||
result.append(addnodes.desc_sig_punctuation('', ']'))
|
result.append(addnodes.desc_sig_punctuation('', ']'))
|
||||||
return result
|
return result
|
||||||
elif isinstance(node, ast.Module):
|
elif isinstance(node, ast.Module):
|
||||||
|
Loading…
Reference in New Issue
Block a user