fix typehinting

This commit is contained in:
fatimah alhumaidhi 2026-01-04 12:49:40 +03:00
parent e712d295a5
commit 1c080720cf
2 changed files with 5 additions and 2 deletions

View File

@ -191,7 +191,7 @@ class BytecodeCache:
return bucket
async def get_bucket_async(
self, environment: Environment, name: str, filename: str | None, source: str
self, environment: "Environment", name: str, filename: str | None, source: str
) -> Bucket:
"""Asynchronously return a cache bucket for the given template. All arguments are
mandatory but filename may be `None`.

View File

@ -1449,7 +1449,7 @@ class Template:
enable_async: bool = False,
) -> t.Any: # it returns a `Template`, but this breaks the sphinx build...
env = get_spontaneous_environment(
type(self.environment),
cls.environment_class, # type: ignore
block_start_string,
block_end_string,
variable_start_string,
@ -1812,6 +1812,8 @@ class TemplateModule:
name = repr(self.__name__)
return f"<{type(self).__name__} {name}>"
class AsyncTemplate(Template):
environment_class: type[Environment] = AsyncEnvironment
class TemplateExpression:
"""The :meth:`jinja2.Environment.compile_expression` method returns an
@ -1929,3 +1931,4 @@ class TemplateStream:
# hook in default template class. if anyone reads this comment: ignore that
# it's possible to use custom templates ;-)
Environment.template_class = Template
AsyncEnvironment.template_class = AsyncTemplate