Skip to content

Commit

Permalink
Fix and add a few type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Sep 2, 2021
1 parent a8d10e8 commit 259410b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sphinxcontrib/bibtex/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BibliographyValue(NamedTuple):
labelprefix: str #: String prefix for pybtex generated labels.
keyprefix: str #: String prefix for citation keys.
filter_: ast.AST #: Parsed filter expression.
citation_nodes: Dict[str, docutils.nodes.citation] #: key -> citation node
citation_nodes: Dict[str, docutils.nodes.Element] #: key -> citation node
keys: List[str] #: Keys listed as content of the directive.


Expand Down Expand Up @@ -148,8 +148,8 @@ def run(self):
for bibfile in bibfiles:
env.note_dependency(bibfile)
# generate nodes and ids
keyprefix = self.options.get("keyprefix", "")
list_ = self.options.get("list", "citation")
keyprefix: str = self.options.get("keyprefix", "")
list_: str = self.options.get("list", "citation")
if list_ not in {"bullet", "enumerated", "citation"}:
logger.warning(
"unknown bibliography list type '{0}'.".format(list_),
Expand All @@ -165,8 +165,9 @@ def run(self):
# we only know which citations to included at resolve stage
# but we need to know their ids before resolve stage
# so for now we generate a node, and thus, an id, for every entry
citation_nodes = {keyprefix + entry.key: citation_node_class()
for entry in domain.get_entries(bibfiles)}
citation_nodes: Dict[str, docutils.nodes.Element] = {
keyprefix + entry.key: citation_node_class()
for entry in domain.get_entries(bibfiles)}
for citation_node in citation_nodes.values():
self.state.document.note_explicit_target(
citation_node, citation_node)
Expand Down

0 comments on commit 259410b

Please sign in to comment.