From 292e517fb5dae340df3823878e3eb38348e7ea6d Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Wed, 9 Oct 2024 16:10:46 +0200 Subject: [PATCH] Allow non-string values in dummy template render context The implementation of the `render()` method uses the standard library method `string.Template.safe_substitute()` to do the actual formatting, which accepts other value types than `str` and simply calls `__str__()` on them. The `safe_substitute()` method is annotated in typeshed with `object` as the value type for the mapping. However, as `_EngineTemplate` uses `Any` instead, I went with that. --- django-stubs/template/backends/dummy.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/template/backends/dummy.pyi b/django-stubs/template/backends/dummy.pyi index a1fb2b083..a334f7ea1 100644 --- a/django-stubs/template/backends/dummy.pyi +++ b/django-stubs/template/backends/dummy.pyi @@ -10,4 +10,4 @@ class TemplateStrings(BaseEngine): 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: ...