From 58f215a87b16cc7cc3480b9d35e2b4d1d2826fea Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Thu, 24 Feb 2022 20:35:29 +0100 Subject: [PATCH 1/3] Remove unneeded type: ignore annotations --- breathe/directives/class_like.py | 2 +- breathe/directives/content_block.py | 2 +- breathe/directives/file.py | 2 +- breathe/directives/function.py | 2 +- breathe/directives/index.py | 2 +- breathe/directives/item.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/breathe/directives/class_like.py b/breathe/directives/class_like.py index 40792658..aae52cab 100644 --- a/breathe/directives/class_like.py +++ b/breathe/directives/class_like.py @@ -5,7 +5,7 @@ from breathe.renderer.target import create_target_handler from docutils.nodes import Node -from docutils.parsers.rst.directives import unchanged_required, unchanged, flag # type: ignore +from docutils.parsers.rst.directives import unchanged_required, unchanged, flag from typing import Any, List diff --git a/breathe/directives/content_block.py b/breathe/directives/content_block.py index 7f9d5b8e..dfd6ec2e 100644 --- a/breathe/directives/content_block.py +++ b/breathe/directives/content_block.py @@ -7,7 +7,7 @@ from breathe.renderer.target import create_target_handler from docutils.nodes import Node -from docutils.parsers.rst.directives import unchanged_required, flag # type: ignore +from docutils.parsers.rst.directives import unchanged_required, flag from typing import Any, List diff --git a/breathe/directives/file.py b/breathe/directives/file.py index 621a87df..78686516 100644 --- a/breathe/directives/file.py +++ b/breathe/directives/file.py @@ -6,7 +6,7 @@ from breathe.renderer.sphinxrenderer import SphinxRenderer from breathe.renderer.target import create_target_handler -from docutils.parsers.rst.directives import unchanged_required, flag # type: ignore +from docutils.parsers.rst.directives import unchanged_required, flag class _BaseFileDirective(BaseDirective): diff --git a/breathe/directives/function.py b/breathe/directives/function.py index b47b531a..b46c54a1 100644 --- a/breathe/directives/function.py +++ b/breathe/directives/function.py @@ -10,7 +10,7 @@ from breathe.renderer.target import create_target_handler from docutils.nodes import Node -from docutils.parsers.rst.directives import unchanged_required, flag # type: ignore +from docutils.parsers.rst.directives import unchanged_required, flag from sphinx.domains import cpp diff --git a/breathe/directives/index.py b/breathe/directives/index.py index 590971e7..eb39cf6a 100644 --- a/breathe/directives/index.py +++ b/breathe/directives/index.py @@ -7,7 +7,7 @@ from breathe.renderer.target import create_target_handler from docutils.nodes import Node -from docutils.parsers.rst.directives import unchanged_required, flag # type: ignore +from docutils.parsers.rst.directives import unchanged_required, flag from typing import List diff --git a/breathe/directives/item.py b/breathe/directives/item.py index c9bf9af1..8f8dc3ef 100644 --- a/breathe/directives/item.py +++ b/breathe/directives/item.py @@ -7,7 +7,7 @@ from docutils.nodes import Node -from docutils.parsers.rst.directives import unchanged_required, flag # type: ignore +from docutils.parsers.rst.directives import unchanged_required, flag from typing import Any, List From 8178926789b6d013fabe9103f30fbbc29894030d Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Thu, 24 Feb 2022 20:47:33 +0100 Subject: [PATCH 2/3] More typing fix --- breathe/renderer/sphinxrenderer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 2d95c818..4297921e 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -31,7 +31,7 @@ import re import textwrap -from typing import Any, Callable, cast, Dict, List, Optional, Type, Union +from typing import Any, Callable, cast, Dict, List, Optional, Sequence, Type, Union ContentCallback = Callable[[addnodes.desc_content], None] Declarator = Union[addnodes.desc_signature, addnodes.desc_signature_line] @@ -1740,7 +1740,7 @@ def visit_inc(self, node: compoundsuper.incType) -> List[nodes.container]: if not self.app.config.breathe_show_include: return [] - compound_link = [nodes.Text("", node.content_[0].getValue())] + compound_link: List[Node] = [nodes.Text("", node.content_[0].getValue())] if node.get_refid(): compound_link = self.visit_docreftext(node) if node.local == "yes": @@ -1748,7 +1748,7 @@ def visit_inc(self, node: compoundsuper.incType) -> List[nodes.container]: else: text = [nodes.Text("#include <"), *compound_link, nodes.Text(">")] - return [nodes.container("", nodes.emphasis("", *text))] + return [nodes.container("", nodes.emphasis("", "", *text))] def visit_ref(self, node: compoundsuper.refType) -> List[Node]: def get_node_info(file_data): @@ -1861,7 +1861,7 @@ def visit_docvarlistentry(self, node) -> List[Node]: content = node.term.content_ return self.render_iterable(content) - def visit_docanchor(self, node) -> List[Node]: + def visit_docanchor(self, node) -> Sequence[Node]: return self.create_doxygen_target(node) def visit_docentry(self, node) -> List[Node]: From 8f217360271c79169e32509f33c3074e532f03eb Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Thu, 24 Feb 2022 21:00:40 +0100 Subject: [PATCH 3/3] Fix typing of visit functions --- breathe/renderer/sphinxrenderer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 4297921e..65a2d0d1 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -31,7 +31,7 @@ import re import textwrap -from typing import Any, Callable, cast, Dict, List, Optional, Sequence, Type, Union +from typing import Any, Callable, cast, Dict, List, Optional, Type, Union ContentCallback = Callable[[addnodes.desc_content], None] Declarator = Union[addnodes.desc_signature, addnodes.desc_signature_line] @@ -990,7 +990,7 @@ def render_declaration(self, node, declaration=None, description=None, **kwargs) return nodes def visit_doxygen(self, node) -> List[Node]: - nodelist = [] + nodelist: List[Node] = [] # Process all the compound children for n in node.get_compound(): @@ -1736,7 +1736,7 @@ def visit_verbatim(self, node) -> List[Node]: return [rst_node] - def visit_inc(self, node: compoundsuper.incType) -> List[nodes.container]: + def visit_inc(self, node: compoundsuper.incType) -> List[Node]: if not self.app.config.breathe_show_include: return [] @@ -1861,8 +1861,8 @@ def visit_docvarlistentry(self, node) -> List[Node]: content = node.term.content_ return self.render_iterable(content) - def visit_docanchor(self, node) -> Sequence[Node]: - return self.create_doxygen_target(node) + def visit_docanchor(self, node) -> List[Node]: + return list(self.create_doxygen_target(node)) def visit_docentry(self, node) -> List[Node]: col = nodes.entry() @@ -2196,7 +2196,7 @@ def visit_friendclass(self, node) -> List[Node]: def visit_templateparam( self, node: compound.paramTypeSub, *, insertDeclNameByParsing: bool = False ) -> List[Node]: - nodelist = [] + nodelist: List[Node] = [] # Parameter type if node.type_: