Skip to content

Commit

Permalink
Fix linter warnings (#1009)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
  • Loading branch information
yut23 and AA-Turner authored Jan 16, 2025
1 parent 685b3bc commit f675265
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install ".[lint]"
- name: Type check with mypy
run: mypy --warn-redundant-casts --warn-unused-ignores breathe tests
run: mypy --warn-redundant-casts --warn-unused-ignores --python-version 3.9 breathe tests

twine:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ black:

.PHONY: type-check
type-check:
mypy --warn-redundant-casts --warn-unused-ignores breathe tests
mypy --warn-redundant-casts --warn-unused-ignores --python-version 3.9 breathe tests
10 changes: 6 additions & 4 deletions breathe/directives/content_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ class DoxygenNamespaceDirective(_DoxygenContentBlockDirective):
class DoxygenGroupDirective(_DoxygenContentBlockDirective):
kind = "group"
option_spec = _DoxygenContentBlockDirective.option_spec.copy()
option_spec.update({
"inner": flag,
"no-title": flag
})
option_spec.update(
{
"inner": flag,
"no-title": flag,
}
)


class DoxygenPageDirective(_DoxygenContentBlockDirective):
Expand Down
4 changes: 2 additions & 2 deletions breathe/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class ParserError(Exception):
def __init__(self, error: Exception, filename: str):
def __init__(self, error: Exception, filename: Path):
super().__init__(error)

self.error = error
Expand All @@ -21,7 +21,7 @@ def __str__(self):


class FileIOError(Exception):
def __init__(self, error: Exception, filename: str):
def __init__(self, error: Exception, filename: Path):
super().__init__(error)

self.error = error
Expand Down
2 changes: 1 addition & 1 deletion breathe/renderer/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def allow(self, node_stack) -> bool:
# If the target_file contains directory separators then
# match against the same length at the end of the location
#
location_match = location[-len(self.target_file):]
location_match = location[-len(self.target_file) :]
return location_match == self.target_file
else:
# If there are no separators, match against the whole filename
Expand Down
20 changes: 13 additions & 7 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def pullup(node, typ, dest):
if self.app.config.breathe_order_parameters_first:
return detailed + fieldLists + admonitions
else:
return detailed + admonitions + fieldLists
return detailed + admonitions + fieldLists # type: ignore[operator]

def update_signature(self, signature, obj_type):
"""Update the signature node if necessary, e.g. add qualifiers."""
Expand Down Expand Up @@ -1204,9 +1204,15 @@ def render_signature(file_data, doxygen_target, name, kind):

# Set up the title

if kind in ["group", "page"] and file_data.compounddef and file_data.compounddef.title:
if (
kind in ["group", "page"]
and file_data.compounddef
and file_data.compounddef.title
):
if "no-title" not in options:
full_title = " ".join([i.getValue() for i in file_data.compounddef.title.content_])
full_title = " ".join(
[i.getValue() for i in file_data.compounddef.title.content_]
)
title_signode.append(nodes.emphasis(text=kind))
title_signode.append(nodes.Text(" "))
title_signode.append(addnodes.desc_name(text=full_title))
Expand Down Expand Up @@ -1883,7 +1889,7 @@ def visit_docrow(self, node) -> List[Node]:
row = nodes.row()
cols = self.render_iterable(node.entry)
elem: Union[nodes.thead, nodes.tbody]
if all(col.get("heading", False) for col in cols):
if all(col.get("heading", False) for col in cols): # type: ignore[attr-defined]
elem = nodes.thead()
else:
elem = nodes.tbody()
Expand All @@ -1906,9 +1912,9 @@ def visit_doctable(self, node) -> List[Node]:
# "envelop" rows there, namely thead and tbody (eg it will need to be updated
# if Doxygen one day adds support for tfoot)

tags: Dict[str, List] = {row.starttag(): [] for row in rows}
tags: Dict[str, List] = {row.starttag(): [] for row in rows} # type: ignore[attr-defined]
for row in rows:
tags[row.starttag()].append(row.next_node())
tags[row.starttag()].append(row.next_node()) # type: ignore[attr-defined]

def merge_row_types(root, elem, elems):
for node in elems:
Expand Down Expand Up @@ -2031,7 +2037,7 @@ def visit_function(self, node) -> List[Node]:
# Insert Doxygen target into the first signature node.
if not self.app.env.config.breathe_debug_trace_doxygen_ids:
target = self.create_doxygen_target(node)
rst_node.children[0].insert(0, target)
rst_node.children[0].insert(0, target) # type: ignore[attr-defined]

finder.content.extend(self.description(node))
return nodes_
Expand Down
1 change: 1 addition & 0 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def mask(self, node):
class MockContext:
def __init__(self, app, node_stack, domain=None, options=[]):
from docutils.statemachine import StringList

self.domain = domain
self.node_stack = node_stack
self.directive_args = [
Expand Down

0 comments on commit f675265

Please sign in to comment.