From 4104b93c6eeccd622652d20a187b77acf7accc7e Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 13 May 2017 15:03:11 +0900 Subject: [PATCH] Fix #3320: Warning about reference target not being found for container types --- CHANGES | 1 + sphinx/domains/python.py | 2 +- tests/roots/test-domain-py/module.rst | 7 +++++++ tests/test_domain_py.py | 6 +++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index ce0c97af8..5c5f55586 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Bugs fixed * #3708: LaTeX writer allows irc scheme * #3717: Stop enforcing that favicon's must be .ico * #3731, #3732: Protect isenumclass predicate against non-class arguments +* #3320: Warning about reference target not being found for container types Testing -------- diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 11fa719dc..29656d548 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -110,7 +110,7 @@ class PyXrefMixin(object): split_contnode = bool(contnode and contnode.astext() == target) results = [] - for sub_target in sub_targets: + for sub_target in filter(None, sub_targets): if split_contnode: contnode = nodes.Text(sub_target) diff --git a/tests/roots/test-domain-py/module.rst b/tests/roots/test-domain-py/module.rst index f3f138639..deb54629e 100644 --- a/tests/roots/test-domain-py/module.rst +++ b/tests/roots/test-domain-py/module.rst @@ -29,3 +29,10 @@ module .. py:class:: ModTopLevel * Link to :py:class:`ModNoModule` + +.. py:function:: foo(x, y) + + :param x: param x + :type x: int + :param y: param y + :type y: tuple(str, float) diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index 73766e718..6927e9dc2 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -107,7 +107,11 @@ def test_domain_py_xrefs(app, status, warning): 'ModTopLevel', 'class') assert_refnode(refnodes[6], 'module_b.submodule', 'ModTopLevel', 'ModNoModule', 'class') - assert len(refnodes) == 7 + assert_refnode(refnodes[7], False, False, 'int', 'obj') + assert_refnode(refnodes[8], False, False, 'tuple', 'obj') + assert_refnode(refnodes[9], False, False, 'str', 'obj') + assert_refnode(refnodes[10], False, False, 'float', 'obj') + assert len(refnodes) == 11 @pytest.mark.sphinx('dummy', testroot='domain-py')