diff --git a/django-stubs/template/backends/base.pyi b/django-stubs/template/backends/base.pyi index 476b1854e..76c1a194d 100644 --- a/django-stubs/template/backends/base.pyi +++ b/django-stubs/template/backends/base.pyi @@ -2,9 +2,7 @@ from collections.abc import Iterator, Mapping from typing import Any, Protocol, type_check_only from django.http.request import HttpRequest -from django.template.base import Context from django.utils.functional import cached_property -from django.utils.safestring import SafeString class BaseEngine: name: str @@ -23,6 +21,6 @@ class BaseEngine: class _EngineTemplate(Protocol): def render( self, - context: Context | dict[str, Any] | None = ..., + context: dict[str, Any] | None = ..., request: HttpRequest | None = ..., - ) -> SafeString: ... + ) -> str: ... diff --git a/django-stubs/template/backends/django.pyi b/django-stubs/template/backends/django.pyi index 7f88df5ab..6e99b01d9 100644 --- a/django-stubs/template/backends/django.pyi +++ b/django-stubs/template/backends/django.pyi @@ -11,6 +11,8 @@ from .base import BaseEngine, _EngineTemplate class DjangoTemplates(BaseEngine): engine: Engine def __init__(self, params: dict[str, Any]) -> None: ... + def from_string(self, template_code: str) -> Template: ... + def get_template(self, template_name: str) -> Template: ... def get_templatetag_libraries(self, custom_libraries: dict[str, str]) -> dict[str, str]: ... def copy_exception(exc: TemplateDoesNotExist, backend: DjangoTemplates | None = None) -> TemplateDoesNotExist: ... diff --git a/django-stubs/template/backends/dummy.pyi b/django-stubs/template/backends/dummy.pyi index a1fb2b083..41a5f5dfc 100644 --- a/django-stubs/template/backends/dummy.pyi +++ b/django-stubs/template/backends/dummy.pyi @@ -7,7 +7,9 @@ from .base import BaseEngine class TemplateStrings(BaseEngine): def __init__(self, params: dict[str, dict[Any, Any] | list[Any] | bool | str]) -> None: ... + def from_string(self, template_code: str) -> Template: ... + def get_template(self, template_name: str) -> Template: ... class Template(string.Template): template: str - def render(self, context: dict[str, str] | None = ..., request: HttpRequest | None = ...) -> str: ... + def render(self, context: dict[str, Any] | None = ..., request: HttpRequest | None = ...) -> str: ... diff --git a/django-stubs/template/backends/jinja2.pyi b/django-stubs/template/backends/jinja2.pyi index cae83ba8d..68db8daaf 100644 --- a/django-stubs/template/backends/jinja2.pyi +++ b/django-stubs/template/backends/jinja2.pyi @@ -2,6 +2,7 @@ from collections.abc import Callable from typing import Any from _typeshed import Incomplete +from django.http.request import HttpRequest from django.template.exceptions import TemplateSyntaxError from django.utils.functional import cached_property @@ -11,6 +12,8 @@ class Jinja2(BaseEngine): env: Any context_processors: list[str] def __init__(self, params: dict[str, Any]) -> None: ... + def from_string(self, template_code: str) -> Template: ... + def get_template(self, template_name: str) -> Template: ... @cached_property def template_context_processors(self) -> list[Callable]: ... @@ -24,6 +27,6 @@ class Template: backend: Jinja2 origin: Origin def __init__(self, template: Incomplete, backend: Jinja2) -> None: ... - def render(self, context: Incomplete | None = ..., request: Incomplete | None = ...) -> Incomplete: ... + def render(self, context: dict[str, Any] | None = ..., request: HttpRequest | None = ...) -> str: ... def get_exception_info(exception: TemplateSyntaxError) -> dict[str, Any]: ... diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index a9c0302cc..e61e6e607 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -88,4 +88,4 @@ class RequestContext(Context): def bind_template(self, template: Template) -> Iterator[None]: ... def new(self, values: _ContextValues | None = None) -> RequestContext: ... -def make_context(context: Any, request: HttpRequest | None = None, **kwargs: Any) -> Context: ... +def make_context(context: dict[str, Any] | None, request: HttpRequest | None = None, **kwargs: Any) -> Context: ...