Skip to content

Commit

Permalink
Use more specific type for get_source callable return value (#12855)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtheturtle authored Sep 2, 2024
1 parent d347149 commit 0438178
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sphinx/jinja2glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SphinxFileSystemLoader(FileSystemLoader):

def get_source(
self, environment: Environment, template: str
) -> tuple[str, str, Callable]:
) -> tuple[str, str, Callable[[], bool]]:
for searchpath in self.searchpath:
filename = path.join(searchpath, template)
f = open_if_exists(filename)
Expand Down Expand Up @@ -224,7 +224,7 @@ def _newest_template_mtime_name(self) -> tuple[float, str]:

def get_source(
self, environment: Environment, template: str
) -> tuple[str, str, Callable]:
) -> tuple[str, str, Callable[[], bool]]:
loaders = self.loaders
# exclamation mark starts search from theme
if template.startswith('!'):
Expand Down
6 changes: 5 additions & 1 deletion sphinx/util/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ def __init__(self, confdir: str | os.PathLike[str],
self.loaders.append(loader)
self.sysloaders.append(loader)

def get_source(self, environment: Environment, template: str) -> tuple[str, str, Callable]:
def get_source(
self,
environment: Environment,
template: str,
) -> tuple[str, str, Callable[[], bool]]:
if template.startswith('!'):
# search a template from ``system_templates_paths``
loaders = self.sysloaders
Expand Down

0 comments on commit 0438178

Please sign in to comment.