Skip to content

Commit

Permalink
Fix some docutils mypy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Feb 8, 2022
1 parent 428d0c1 commit deaec6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/sphinxcontrib/bibtex/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.. autoattribute:: default_priority
.. automethod:: run
"""
from itertools import zip_longest

import docutils.nodes

Expand All @@ -25,15 +26,15 @@

def node_text_transform(node: docutils.nodes.Element) -> None:
"""Apply extra text transformations to a node."""
for child, next_child in zip(node.children[:], node.children[1:] + [None]):
for child, next_child in zip_longest(node.children[:], node.children[1:]):
if isinstance(child, docutils.nodes.Text):
if (child.endswith(r'\url ')
and isinstance(next_child, docutils.nodes.Text)):
node.replace(child, docutils.nodes.Text(child[:-5]))
ref_node = docutils.nodes.reference(refuri=next_child.astext())
ref_node += next_child
node.replace(next_child, ref_node)
else:
elif isinstance(child, docutils.nodes.Element):
node_text_transform(child)


Expand Down
3 changes: 2 additions & 1 deletion test/natbib.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def result_nodes(self, document: nodes.document, env: BuildEnvironment,
'global_keys': env.domaindata['cite']['keys'],
'config': config}

node += nodes.pending(CitationTransform, data)
# TODO bad design here, pending is meant to get the Transform object
node += nodes.pending(CitationTransform, data) # type: ignore
return [node], []


Expand Down

0 comments on commit deaec6d

Please sign in to comment.