-
-
Notifications
You must be signed in to change notification settings - Fork 507
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
What's wrong
We received an update in cookiecutter-django to update to the latest django-stubs, but the type checks fail:
The reason is because the success_message
attribute for SuccessMessageMixin
should accept lazy string.
django-stubs/django-stubs/contrib/messages/views.pyi
Lines 6 to 9 in 8f97bf8
class SuccessMessageMixin: | |
success_message: str = ... | |
def form_valid(self, form: BaseForm) -> HttpResponse: ... | |
def get_success_message(self, cleaned_data: Dict[str, str]) -> str: ... |
References:
- Return Promise for lazy functions. #689
- Error while passing gettext_lazy to arguments expecting strings #1137
I assume there are a other mixin with the same problem.
Related error:
Note that the CI run above also have a similar error regarding the model admin fieldsets
attribute (defined here) - I'm happy to open a separate issue about it, but maybe we should consider a overall fix?
How is that should be
The type annotation for success_message should accept lazy strings too:
class SuccessMessageMixin:
success_message: _StrOrPromise = ...
System information
- OS:
python
version: 3.10django
version: 4.0mypy
version: 0.982django-stubs
version: 1.13.0django-stubs-ext
version: n/a (I don't think this package is installed?)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working