diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-30 01:41:18 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-30 01:48:25 +0900 |
commit | a99675bf78eec8024792da6448e89ea534c59b5a (patch) | |
tree | 1ba6462010c858e853a00fbbae1036d6d296a9d0 /tests/test_domain_py.py | |
parent | bb65ea7930205ff54986136cd519c32a83407087 (diff) | |
download | sphinx-git-a99675bf78eec8024792da6448e89ea534c59b5a.tar.gz |
Fix #8008: py domain: failed to parse a type annotation containing ellipsis
Fix _parse_annotation() does not support a type annotation having ellipsis.
Diffstat (limited to 'tests/test_domain_py.py')
-rw-r--r-- | tests/test_domain_py.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index ccf539b6d..b98f37912 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -262,6 +262,14 @@ def test_parse_annotation(app): [desc_sig_punctuation, ")"], [desc_sig_punctuation, "]"])) + doctree = _parse_annotation("Tuple[int, ...]", app.env) + assert_node(doctree, ([pending_xref, "Tuple"], + [desc_sig_punctuation, "["], + [pending_xref, "int"], + [desc_sig_punctuation, ", "], + [desc_sig_punctuation, "..."], + [desc_sig_punctuation, "]"])) + doctree = _parse_annotation("Callable[[int, int], int]", app.env) assert_node(doctree, ([pending_xref, "Callable"], [desc_sig_punctuation, "["], @@ -274,6 +282,12 @@ def test_parse_annotation(app): [pending_xref, "int"], [desc_sig_punctuation, "]"])) + doctree = _parse_annotation("List[None]", app.env) + assert_node(doctree, ([pending_xref, "List"], + [desc_sig_punctuation, "["], + [pending_xref, "None"], + [desc_sig_punctuation, "]"])) + # None type makes an object-reference (not a class reference) doctree = _parse_annotation("None", app.env) assert_node(doctree, ([pending_xref, "None"],)) |