Use more specific type for get_source callable return value (#12855)

This commit is contained in:
Adam Dangoor 2024-09-02 16:32:17 +01:00 committed by GitHub
parent d347149f55
commit 04381789db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -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 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
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('!'):

View File

@ -124,7 +124,11 @@ class SphinxTemplateLoader(BaseLoader):
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