Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update django.template.base.Template.render() argument type #1160

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion django-stubs/template/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Template:
name: str | None = ...,
engine: Engine | None = ...,
) -> None: ...
def render(self, context: Context | dict[str, Any] | None) -> SafeString: ...
def render(self, context: Context) -> SafeString: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this has to be compatible with django.template.backends.base._EngineTemplate protocol defined in django-stubs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait. There are two Template classes in Django

django.template.base.Template.render() doesn't support dict, but django.template.backends.django.Template.render() is a wrapper class that does support dict and None.

django.template.backends.django.DjangoTemplates.get_template() wraps the first Template in the latter wrapper class. Confusing!

def compile_nodelist(self) -> NodeList: ...
def get_exception_info(self, exception: Exception, token: Token) -> dict[str, Any]: ...

Expand Down