Skip to content

Do not override type checks for test_util_fileutil #13552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ module = [
# tests/test_transforms
"tests.test_transforms.test_transforms_post_transforms",
# tests/test_util
"tests.test_util.test_util_fileutil",
"tests.test_util.test_util_i18n",
"tests.test_util.test_util_inspect",
"tests.test_util.test_util_logging",
Expand Down
9 changes: 5 additions & 4 deletions tests/test_util/test_util_fileutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from sphinx._cli.util.errors import strip_escape_sequences
from sphinx.jinja2glue import BuiltinTemplateLoader
from sphinx.util.fileutil import _template_basename, copy_asset, copy_asset_file
from sphinx.util.template import BaseRenderer

if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp


class DummyTemplateLoader(BuiltinTemplateLoader):
class DummyTemplateLoader(BuiltinTemplateLoader, BaseRenderer):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instances of this are given as the renderer parameter to copy_asset_file which is defined with renderer: BaseRenderer | None = None.

def __init__(self) -> None:
super().__init__()
builder = mock.Mock()
Expand All @@ -26,7 +27,7 @@ def __init__(self) -> None:
self.init(builder)


def test_copy_asset_file(tmp_path):
def test_copy_asset_file(tmp_path: Path) -> None:
renderer = DummyTemplateLoader()

# copy normal file
Expand Down Expand Up @@ -69,7 +70,7 @@ def test_copy_asset_file(tmp_path):
assert (subdir2 / 'asset.txt.jinja').read_text(encoding='utf8') == '# {{var1}} data'


def test_copy_asset(tmp_path):
def test_copy_asset(tmp_path: Path) -> None:
renderer = DummyTemplateLoader()

# prepare source files
Expand Down Expand Up @@ -113,7 +114,7 @@ def test_copy_asset(tmp_path):
assert sidebar == 'sidebar: baz'

# copy with exclusion
def excluded(path):
def excluded(path: str) -> bool:
return 'sidebar.html' in path or 'basic.css' in path

destdir = tmp_path / 'test3'
Expand Down
Loading