Skip to content

Conversation

@mkurnikov
Copy link
Member

No description provided.

@mkurnikov mkurnikov changed the title Improvements to annotations Various annotation improvements Dec 12, 2019
@mkurnikov mkurnikov merged commit f020509 into typeddjango:master Dec 12, 2019
kalekseev pushed a commit to kalekseev/django-stubs that referenced this pull request Aug 24, 2024
Big improvements here are:

- `template.Template.render` now returns `SafeText` instead of `Any`.
- [`DjangoDivFormRenderer`](https://docs.djangoproject.com/en/4.2/ref/forms/renderers/#django.forms.renderers.DjangoDivFormRenderer) and [`Jinja2DivFormRenderer`](https://docs.djangoproject.com/en/4.2/ref/forms/renderers/#django.forms.renderers.Jinja2DivFormRenderer) in `forms.renderers`.
- A `template.backends.base._BaseTemplate` [protocol class](https://docs.python.org/3/library/typing.html#typing.Protocol) that imitates the abstract [`BaseTemplate` class from DEP 182](https://github.com/django/deps/blob/main/final/0182-multiple-template-engines.rst#backends-api). This is needed because there is no real parent class from which each template backend inherits from, they implement their own `Template` classes from scratch. So, `BaseEngine` needed a return type for its abstract methods, which is what `_BaseTemplate` provides.

Other changes include reducing repetition, adding more specific Template types for the different backends, using more generic `Mapping` type instead of `dict` for template contexts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant