From 04381789db7466d56d9eb29d23d979fc16604acc Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 2 Sep 2024 16:32:17 +0100 Subject: [PATCH] Use more specific type for get_source callable return value (#12855) --- sphinx/jinja2glue.py | 4 ++-- sphinx/util/template.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index 0df58b52d4f..5436900db12 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -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) @@ -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('!'): diff --git a/sphinx/util/template.py b/sphinx/util/template.py index 2b38e3a8678..1cfc287a821 100644 --- a/sphinx/util/template.py +++ b/sphinx/util/template.py @@ -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