From a99675bf78eec8024792da6448e89ea534c59b5a Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 30 Jul 2020 01:41:18 +0900 Subject: Fix #8008: py domain: failed to parse a type annotation containing ellipsis Fix _parse_annotation() does not support a type annotation having ellipsis. --- tests/test_domain_py.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/test_domain_py.py') 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"],)) -- cgit v1.2.1