Skip to content

Commit 29c50c8

Browse files
committed
Add missing type annotation in docs/
1 parent ff19eca commit 29c50c8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/pip_sphinxext.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import sys
77
from textwrap import dedent
8-
from typing import Iterable, List, Optional
8+
from typing import Iterable, Iterator, List, Optional
99

1010
from docutils import nodes, statemachine
1111
from docutils.parsers import rst
@@ -20,7 +20,9 @@
2020
class PipNewsInclude(rst.Directive):
2121
required_arguments = 1
2222

23-
def _is_version_section_title_underline(self, prev, curr):
23+
def _is_version_section_title_underline(
24+
self, prev: Optional[str], curr: str
25+
) -> bool:
2426
"""Find a ==== line that marks the version section title."""
2527
if prev is None:
2628
return False
@@ -30,7 +32,7 @@ def _is_version_section_title_underline(self, prev, curr):
3032
return False
3133
return True
3234

33-
def _iter_lines_with_refs(self, lines):
35+
def _iter_lines_with_refs(self, lines: Iterable[str]) -> Iterator[str]:
3436
"""Transform the input lines to add a ref before each section title.
3537
3638
This is done by looking one line ahead and locate a title's underline,
@@ -44,6 +46,7 @@ def _iter_lines_with_refs(self, lines):
4446
for line in lines:
4547
# Transform the previous line to include an explicit ref.
4648
if self._is_version_section_title_underline(prev, line):
49+
assert prev is not None
4750
vref = prev.split(None, 1)[0].replace(".", "-")
4851
yield f".. _`v{vref}`:"
4952
yield "" # Empty line between ref and the title.
@@ -53,7 +56,7 @@ def _iter_lines_with_refs(self, lines):
5356
if prev is not None:
5457
yield prev
5558

56-
def run(self):
59+
def run(self) -> List[nodes.Node]:
5760
source = self.state_machine.input_lines.source(
5861
self.lineno - self.state_machine.input_offset - 1,
5962
)

0 commit comments

Comments
 (0)