Skip to content

Commit 3754750

Browse files
committed
Update type hints.
1 parent 6ef988d commit 3754750

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ To install with ``pip``:
113113
114114
.. end installation
115115
116-
Then enable the extension by adding the following to your ``conf.py`` file::
116+
Then enable the extension by adding the following to your ``conf.py`` file:
117117

118118
.. code-block:: python
119119
120120
extensions = [
121-
..., # Other extensions go here
122-
"html_section",
123-
]
121+
..., # Other extensions go here
122+
"html_section",
123+
]
124124
125125
126126
Usage

html_section/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ def apply(self, **kwargs) -> None: # noqa: D102
223223
node.parent.replace_self(node.parent.children[node.parent.children.index(node):])
224224

225225

226-
def purge_outdated(app: Sphinx, env, added, changed, removed):
226+
def purge_outdated(
227+
app: Sphinx,
228+
env: BuildEnvironment,
229+
added: List[str],
230+
changed: List[str],
231+
removed: List[str],
232+
):
227233
return [
228234
*getattr(env, "html_only_node_docnames", []),
229235
*getattr(env, "phantom_node_docnames", []),

tests/test_output.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33
import shutil
44
import sys
5-
from typing import Union
5+
from typing import Union, cast
66

77
# 3rd party
88
import pytest
@@ -11,8 +11,11 @@
1111
from coincidence.regressions import AdvancedFileRegressionFixture
1212
from domdf_python_tools.paths import PathPlus
1313
from domdf_python_tools.stringlist import StringList
14+
from domdf_python_tools.typing import PathLike
1415
from jinja2 import Template
1516
from pytest_regressions.common import check_text_files
17+
from sphinx.application import Sphinx
18+
from sphinx.builders import Builder
1619
from sphinx_toolbox.testing import HTMLRegressionFixture
1720

1821

@@ -30,20 +33,20 @@ def doc_root(tmp_pathplus: PathPlus):
3033

3134
@pytest.mark.usefixtures("doc_root")
3235
@pytest.mark.sphinx("html", testroot="test-html-section")
33-
def test_build_example(app):
36+
def test_build_example(app: Sphinx):
3437
app.build()
3538
app.build()
3639

3740

3841
@pytest.mark.usefixtures("doc_root")
3942
@pytest.mark.sphinx("html", testroot="test-html-section")
40-
def test_html_output(app, html_regression: HTMLRegressionFixture):
43+
def test_html_output(app: Sphinx, html_regression: HTMLRegressionFixture):
4144

42-
assert app.builder.name.lower() == "html"
45+
assert cast(Builder, app.builder).name.lower() == "html"
4346

4447
app.build(force_all=True)
4548

46-
output_file = PathPlus(app.outdir / "index.html")
49+
output_file = PathPlus(app.outdir) / "index.html"
4750
page = BeautifulSoup(output_file.read_text(), "html5lib")
4851
html_regression.check(page, jinja2=False)
4952

@@ -76,8 +79,7 @@ def check( # type: ignore
7679

7780
__tracebackhide__ = True
7881

79-
def check_fn(obtained_filename, expected_filename):
80-
print(obtained_filename, expected_filename)
82+
def check_fn(obtained_filename: PathPlus, expected_filename: PathLike):
8183
expected_filename = PathPlus(expected_filename)
8284

8385
template = Template(
@@ -123,11 +125,11 @@ def latex_regression(datadir, original_datadir, request) -> LaTeXRegressionFixtu
123125

124126
@pytest.mark.usefixtures("doc_root")
125127
@pytest.mark.sphinx("latex", testroot="test-html-section")
126-
def test_latex_output(app, latex_regression: LaTeXRegressionFixture):
128+
def test_latex_output(app: Sphinx, latex_regression: LaTeXRegressionFixture):
127129

128-
assert app.builder.name.lower() == "latex"
130+
assert cast(Builder, app.builder).name.lower() == "latex"
129131

130132
app.build(force_all=True)
131133

132-
output_file = PathPlus(app.outdir / "python.tex")
134+
output_file = PathPlus(app.outdir) / "python.tex"
133135
latex_regression.check(StringList(output_file.read_lines()))

0 commit comments

Comments
 (0)