Skip to content

Commit 6ccd00f

Browse files
committed
Lint
1 parent 8f0214c commit 6ccd00f

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

sphinx_highlights/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import sys
4242
from importlib import import_module
4343
from types import FunctionType
44-
from typing import Iterable, Iterator, List, Optional, TypeVar, Union, get_type_hints
44+
from typing import Iterable, Iterator, List, Optional, Set, TypeVar, Union, get_type_hints
4545

4646
# 3rd party
4747
import dict2css
@@ -59,6 +59,7 @@
5959

6060
# 3rd party
6161
from sphinx.application import Sphinx
62+
from sphinx.environment import BuildEnvironment
6263
from sphinx.util.docutils import SphinxDirective
6364
from sphinx_toolbox.more_autodoc.typehints import format_annotation
6465
from sphinx_toolbox.utils import Purger, SphinxExtMetadata
@@ -261,7 +262,7 @@ def run_html(self) -> List[nodes.Node]:
261262

262263
view = ViewList(content)
263264
body_node = nodes.paragraph(rawsource=str(content))
264-
self.state.nested_parse(view, self.content_offset, body_node) # type: ignore
265+
self.state.nested_parse(view, self.content_offset, body_node) # type: ignore[arg-type]
265266

266267
sphinx_highlights_purger.add_node(self.env, body_node, targetnode, self.lineno)
267268

@@ -302,7 +303,7 @@ def run_generic(self) -> List[nodes.Node]:
302303

303304
view = ViewList(content)
304305
body_node = nodes.container(rawsource=str(content))
305-
self.state.nested_parse(view, self.content_offset, body_node) # type: ignore
306+
self.state.nested_parse(view, self.content_offset, body_node) # type: ignore[arg-type]
306307

307308
sphinx_highlights_purger.add_node(self.env, body_node, targetnode, self.lineno)
308309

@@ -361,7 +362,13 @@ def copy_assets(app: Sphinx, exception: Optional[Exception] = None) -> None:
361362
dict2css.dump(style, css_dir / "sphinx_highlights.css")
362363

363364

364-
def env_get_outdated(app, env, added, changed, removed):
365+
def env_get_outdated(
366+
app: Sphinx,
367+
env: BuildEnvironment,
368+
added: Set[str],
369+
changed: Set[str],
370+
removed: Set[str],
371+
) -> List[str]:
365372
return [node["docname"] for node in getattr(env, sphinx_highlights_purger.attr_name, ())]
366373

367374

sphinx_highlights/_eval_type.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
if sys.version_info >= (3, 9): # pragma: no cover (<py39)
4545

46-
def _eval_type(t, globalns, localns, recursive_guard=frozenset()):
46+
def _eval_type(t, globalns, localns, recursive_guard=frozenset()): # noqa: MAN001,MAN002
4747
"""
4848
Evaluate all forward references in the given type t.
4949
@@ -78,7 +78,7 @@ def _eval_type(t, globalns, localns, recursive_guard=frozenset()):
7878

7979
elif sys.version_info >= (3, 7): # pragma: no cover (py39+ or <py37)
8080

81-
def _eval_type(t, globalns, localns):
81+
def _eval_type(t, globalns, localns): # noqa: MAN001,MAN002
8282
"""
8383
Evaluate all forward references in the given type t.
8484
@@ -110,7 +110,7 @@ def _eval_type(t, globalns, localns):
110110

111111

112112
@contextlib.contextmanager
113-
def monkeypatcher():
113+
def monkeypatcher() -> typing.Iterator[None]:
114114
"""
115115
Use the modified version of ``typing._eval_type`` for the scope of the :keyword:`with` block.
116116
"""

tests/test_output/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import pytest
3535
from bs4 import BeautifulSoup
3636
from domdf_python_tools.paths import PathPlus
37+
from sphinx.application import Sphinx
3738
from sphinx.testing.fixtures import app, make_app, shared_result, sphinx_test_tempdir, test_params
3839
from sphinx.testing.path import path
3940

@@ -48,7 +49,7 @@
4849
]
4950

5051

51-
def pytest_configure(config):
52+
def pytest_configure(config) -> None: # noqa: MAN001
5253
# register custom markers
5354
for marker in DEFAULT_ENABLED_MARKERS:
5455
config.addinivalue_line("markers", marker)
@@ -60,7 +61,7 @@ class AppParams(NamedTuple):
6061

6162

6263
@pytest.fixture(scope="session")
63-
def rootdir():
64+
def rootdir() -> path:
6465
rdir = PathPlus(__file__).parent.absolute() / "doc-test"
6566
(rdir / "test-root").maybe_make(parents=True)
6667
return path(rdir)
@@ -107,7 +108,7 @@ def app_params(
107108

108109

109110
@pytest.fixture()
110-
def page(app, request, monkeypatch) -> Iterator[BeautifulSoup]:
111+
def page(app: Sphinx, request, monkeypatch) -> Iterator[BeautifulSoup]:
111112
random.seed("5678")
112113

113114
app.build(force_all=True)

tests/test_output/test_output.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
from bs4 import BeautifulSoup
88
from domdf_python_tools.paths import PathPlus
99
from domdf_python_tools.stringlist import StringList
10+
from sphinx.application import Sphinx
1011
from sphinx_toolbox.testing import HTMLRegressionFixture, LaTeXRegressionFixture
1112

1213

13-
def test_build_example(app):
14+
def test_build_example(app: Sphinx):
1415
app.build()
1516
app.build()
1617

@@ -35,15 +36,16 @@ def test_html_output(page: BeautifulSoup, html_regression: HTMLRegressionFixture
3536

3637
@pytest.mark.sphinx("latex", srcdir="test-root")
3738
def test_latex_output(
38-
app,
39+
app: Sphinx,
3940
latex_regression: LaTeXRegressionFixture,
4041
):
4142
random.seed("5678")
4243

44+
assert app.builder is not None
4345
assert app.builder.name.lower() == "latex"
4446
app.build()
4547

46-
output_file = PathPlus(app.outdir / "sphinx-highlights-demo.tex")
48+
output_file = PathPlus(app.outdir) / "sphinx-highlights-demo.tex"
4749
content = str(StringList(output_file.read_lines())).replace("\\sphinxAtStartPar\n", '')
4850
latex_regression.check(
4951
# re.sub(r"\\date{.*}", r"\\date{Mar 11, 2021}", content),

0 commit comments

Comments
 (0)