Skip to content

Commit 4a40148

Browse files
committed
Convert type comments to annotations
1 parent b3c0725 commit 4a40148

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

sphinxcontrib/htmlhelp/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
:license: BSD, see LICENSE for details.
99
"""
1010

11+
from __future__ import annotations
12+
1113
import html
1214
import os
1315
from os import path
1416
from pathlib import Path
15-
from typing import Any, Dict, List, Set, Tuple, Type
17+
from typing import Any
1618

1719
from docutils import nodes
1820
from docutils.nodes import Element, Node, document
@@ -99,7 +101,7 @@ def chm_htmlescape(s: str, quote: bool = True) -> str:
99101
class ToCTreeVisitor(nodes.NodeVisitor):
100102
def __init__(self, document: document) -> None:
101103
super().__init__(document)
102-
self.body = [] # type: List[str]
104+
self.body: list[str] = []
103105
self.depth = 0
104106

105107
def append(self, text: str) -> None:
@@ -175,15 +177,15 @@ def init(self) -> None:
175177
self.lcid, self.encoding = locale
176178

177179
@property
178-
def default_translator_class(self) -> "Type[nodes.NodeVisitor]": # type: ignore
180+
def default_translator_class(self) -> type[nodes.NodeVisitor]:
179181
# Use HTML4 writer always
180182
return HTMLTranslator
181183

182-
def prepare_writing(self, docnames: Set[str]) -> None:
184+
def prepare_writing(self, docnames: set[str]) -> None:
183185
super().prepare_writing(docnames)
184186
self.globalcontext['html5_doctype'] = False
185187

186-
def update_page_context(self, pagename: str, templatename: str, ctx: Dict, event_arg: str) -> None: # NOQA
188+
def update_page_context(self, pagename: str, templatename: str, ctx: dict, event_arg: str) -> None: # NOQA
187189
ctx['encoding'] = self.encoding
188190

189191
def handle_finish(self) -> None:
@@ -200,7 +202,7 @@ def write_doc(self, docname: str, doctree: document) -> None:
200202

201203
super().write_doc(docname, doctree)
202204

203-
def render(self, name: str, context: Dict) -> str:
205+
def render(self, name: str, context: dict) -> str:
204206
template = SphinxRenderer(template_dir)
205207
return template.render(name, context)
206208

@@ -223,7 +225,7 @@ def copy_stopword_list(self) -> None:
223225
def build_project_file(self) -> None:
224226
"""Create a project file (.hhp) on outdir."""
225227
# scan project files
226-
project_files = [] # type: List[str]
228+
project_files: list[str] = []
227229
for root, dirs, files in os.walk(self.outdir):
228230
dirs.sort()
229231
files.sort()
@@ -275,7 +277,7 @@ def build_hhx(self, outdir: Path, outname: str) -> None:
275277
with open(filename, 'w', encoding=self.encoding, errors='xmlcharrefreplace') as f:
276278
f.write('<UL>\n')
277279

278-
def write_index(title: str, refs: List[Tuple[str, str]], subitems: List[Tuple[str, List[Tuple[str, str]]]]) -> None: # NOQA
280+
def write_index(title: str, refs: list[tuple[str, str]], subitems: list[tuple[str, list[tuple[str, str]]]]) -> None: # NOQA
279281
def write_param(name: str, value: str) -> None:
280282
item = ' <param name="%s" value="%s">\n' % (name, value)
281283
f.write(item)
@@ -308,7 +310,7 @@ def default_htmlhelp_basename(config: Config) -> str:
308310
return make_filename_from_project(config.project) + 'doc'
309311

310312

311-
def setup(app: Sphinx) -> Dict[str, Any]:
313+
def setup(app: Sphinx) -> dict[str, Any]:
312314
app.setup_extension('sphinx.builders.html')
313315
app.add_builder(HTMLHelpBuilder)
314316
app.add_message_catalog(__name__, path.join(package_dir, 'locales'))

0 commit comments

Comments
 (0)