Skip to content

Commit 03e3202

Browse files
committed
Convert type comments to annotations
1 parent f1f1ff9 commit 03e3202

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

sphinxcontrib/devhelp/__init__.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
:license: BSD, see LICENSE for details.
1111
"""
1212

13+
from __future__ import annotations
14+
1315
import gzip
1416
import re
1517
from os import path
16-
from typing import TYPE_CHECKING, Any, Dict
18+
from typing import TYPE_CHECKING, Any
1719

1820
from docutils import nodes
1921
from sphinx import addnodes
@@ -30,11 +32,8 @@
3032
except ImportError:
3133
import lxml.etree as etree # type: ignore
3234

33-
3435
if TYPE_CHECKING:
35-
# For type annotation
3636
from pathlib import Path
37-
from typing import List # NOQA
3837

3938
__version__ = '1.0.3'
4039
__version_info__ = (1, 0, 3)
@@ -64,18 +63,15 @@ class DevhelpBuilder(StandaloneHTMLBuilder):
6463
# don't add sidebar etc.
6564
embedded = True
6665

67-
def init(self):
68-
# type: () -> None
66+
def init(self) -> None:
6967
super().init()
7068
self.out_suffix = '.html'
7169
self.link_suffix = '.html'
7270

73-
def handle_finish(self):
74-
# type: () -> None
71+
def handle_finish(self) -> None:
7572
self.build_devhelp(self.outdir, self.config.devhelp_basename)
7673

77-
def build_devhelp(self, outdir, outname):
78-
# type: (Path, str) -> None
74+
def build_devhelp(self, outdir: Path, outname: str) -> None:
7975
logger.info(__('dumping devhelp index...'))
8076

8177
# Basic info
@@ -92,8 +88,7 @@ def build_devhelp(self, outdir, outname):
9288
tocdoc = self.env.get_and_resolve_doctree(
9389
self.config.master_doc, self, prune_toctrees=False)
9490

95-
def write_toc(node, parent):
96-
# type: (nodes.Node, etree.Element) -> None
91+
def write_toc(node: nodes.Node, parent: etree.Element) -> None:
9792
if isinstance(node, addnodes.compact_paragraph) or \
9893
isinstance(node, nodes.bullet_list):
9994
for subnode in node:
@@ -114,8 +109,7 @@ def write_toc(node, parent):
114109
functions = etree.SubElement(root, 'functions')
115110
index = IndexEntries(self.env).create_index(self)
116111

117-
def write_index(title, refs, subitems):
118-
# type: (str, List[Any], Any) -> None
112+
def write_index(title: str, refs: list[Any], subitems: Any) -> None:
119113
if len(refs) == 0:
120114
pass
121115
elif len(refs) == 1:
@@ -143,7 +137,7 @@ def write_index(title, refs, subitems):
143137
tree.write(f, 'utf-8') # type: ignore
144138

145139

146-
def setup(app: Sphinx) -> Dict[str, Any]:
140+
def setup(app: Sphinx) -> dict[str, Any]:
147141
app.setup_extension('sphinx.builders.html')
148142
app.add_builder(DevhelpBuilder)
149143
app.add_message_catalog(__name__, path.join(package_dir, 'locales'))

0 commit comments

Comments
 (0)