Skip to content

Commit

Permalink
Convert type comments to annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Aug 7, 2023
1 parent 14fd413 commit 70f7897
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions sphinxcontrib/qthelp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
:license: BSD, see LICENSE for details.
"""

from __future__ import annotations

import html
import os
import posixpath
import re
from os import path
from pathlib import Path
from typing import Any, Dict, Iterable, List, Tuple, cast
from typing import TYPE_CHECKING, Any, cast

from docutils import nodes
from docutils.nodes import Node
Expand All @@ -28,6 +30,9 @@
from sphinx.util.osutil import canon_path, make_filename
from sphinx.util.template import SphinxRenderer

if TYPE_CHECKING:
from collections.abc import Iterable

__version__ = '1.0.4'
__version_info__ = (1, 0, 4)

Expand Down Expand Up @@ -83,7 +88,7 @@ def init(self) -> None:
self.link_suffix = '.html'
# self.config.html_style = 'traditional.css'

def get_theme_config(self) -> Tuple[str, Dict]:
def get_theme_config(self) -> tuple[str, dict]:
return self.config.qthelp_theme, self.config.qthelp_theme_options

def handle_finish(self) -> None:
Expand Down Expand Up @@ -165,8 +170,8 @@ def isdocnode(self, node: Node) -> bool:
return False
return True

def write_toc(self, node: Node, indentlevel: int = 4) -> List[str]:
parts = [] # type: List[str]
def write_toc(self, node: Node, indentlevel: int = 4) -> list[str]:
parts: list[str] = []
if isinstance(node, nodes.list_item) and self.isdocnode(node):
compact_paragraph = cast(addnodes.compact_paragraph, node[0])
reference = cast(nodes.reference, compact_paragraph[0])
Expand Down Expand Up @@ -221,8 +226,8 @@ def keyword_item(self, name: str, ref: Any) -> str:
item.encode('ascii', 'xmlcharrefreplace')
return item

def build_keywords(self, title: str, refs: List[Any], subitems: Any) -> List[str]:
keywords = [] # type: List[str]
def build_keywords(self, title: str, refs: list[Any], subitems: Any) -> list[str]:
keywords: list[str] = []

# if len(refs) == 0: # XXX
# write_param('See Also', title)
Expand All @@ -243,7 +248,7 @@ def build_keywords(self, title: str, refs: List[Any], subitems: Any) -> List[str

return keywords

def get_project_files(self, outdir: Path) -> List[str]:
def get_project_files(self, outdir: Path) -> list[str]:
project_files = []
staticdir = path.join(outdir, '_static')
imagesdir = path.join(outdir, self.imagedir)
Expand All @@ -257,7 +262,7 @@ def get_project_files(self, outdir: Path) -> List[str]:
return project_files


def setup(app: Sphinx) -> Dict[str, Any]:
def setup(app: Sphinx) -> dict[str, Any]:
app.setup_extension('sphinx.builders.html')
app.add_builder(QtHelpBuilder)
app.add_message_catalog(__name__, path.join(package_dir, 'locales'))
Expand Down

0 comments on commit 70f7897

Please sign in to comment.