Skip to content

Commit

Permalink
Allow non-string values in dummy template render context
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mthuurne committed Oct 9, 2024
1 parent 9511a85 commit 292e517
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django-stubs/template/backends/dummy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

0 comments on commit 292e517

Please sign in to comment.