diff --git a/CHANGES b/CHANGES index e7099805500..de8970b8316 100644 --- a/CHANGES +++ b/CHANGES @@ -73,6 +73,8 @@ Features added Bugs fixed ---------- +* #11093: LaTeX: fix build warnings when one or more reST labels directly preceed an + :rst:dir:`py:module` or :rst:dir:`automodule` directive. Patch by Bénédikt Tran (picnixz) * #11079: LaTeX: figures with align attribute may disappear and strangely impact following lists * #11110: LaTeX: Figures go missing from latex pdf if their files have the same diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 684164a1f7d..efb84735398 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1504,14 +1504,14 @@ def add_target(id: str) -> None: if node.get('ismod', False): # Detect if the previous nodes are label targets. If so, remove # the refid thereof from node['ids'] to avoid duplicated ids. - def has_dup_label(sib: Element | None) -> bool: + def has_dup_label(sib: Node | None) -> bool: return isinstance(sib, nodes.target) and sib.get('refid') in node['ids'] - prev: Element | None = get_prev_node(node) + prev = get_prev_node(node) if has_dup_label(prev): ids = node['ids'][:] # copy to avoid side-effects while has_dup_label(prev): - ids.remove(prev['refid']) + ids.remove(prev['refid']) # type: ignore prev = get_prev_node(prev) else: ids = iter(node['ids']) # read-only iterator