mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
Merge pull request #5231 from cookiecutter/pyup-update-mypy-1.10.0-to-1.11.0
Update mypy to 1.11.0
This commit is contained in:
commit
5a61a0c828
|
@ -13,12 +13,12 @@ watchfiles==0.21.0 # https://github.com/samuelcolvin/watchfiles
|
|||
|
||||
# Testing
|
||||
# ------------------------------------------------------------------------------
|
||||
mypy==1.10.0 # https://github.com/python/mypy
|
||||
django-stubs[compatible-mypy]==5.0.2 # https://github.com/typeddjango/django-stubs
|
||||
mypy==1.11.0 # https://github.com/python/mypy
|
||||
django-stubs[compatible-mypy]==5.0.4 # https://github.com/typeddjango/django-stubs
|
||||
pytest==8.3.2 # https://github.com/pytest-dev/pytest
|
||||
pytest-sugar==1.0.0 # https://github.com/Frozenball/pytest-sugar
|
||||
{%- if cookiecutter.use_drf == "y" %}
|
||||
djangorestframework-stubs[compatible-mypy]==3.15.0 # https://github.com/typeddjango/djangorestframework-stubs
|
||||
djangorestframework-stubs==3.15.0 # https://github.com/typeddjango/djangorestframework-stubs
|
||||
{%- endif %}
|
||||
|
||||
# Documentation
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.db.models import QuerySet
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView
|
||||
|
@ -28,12 +29,12 @@ class UserUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
|
|||
fields = ["name"]
|
||||
success_message = _("Information successfully updated")
|
||||
|
||||
def get_success_url(self):
|
||||
# for mypy to know that the user is authenticated
|
||||
assert self.request.user.is_authenticated
|
||||
def get_success_url(self) -> str:
|
||||
assert self.request.user.is_authenticated # type guard
|
||||
return self.request.user.get_absolute_url()
|
||||
|
||||
def get_object(self):
|
||||
def get_object(self, queryset: QuerySet | None=None) -> User:
|
||||
assert self.request.user.is_authenticated # type guard
|
||||
return self.request.user
|
||||
|
||||
|
||||
|
@ -43,7 +44,7 @@ user_update_view = UserUpdateView.as_view()
|
|||
class UserRedirectView(LoginRequiredMixin, RedirectView):
|
||||
permanent = False
|
||||
|
||||
def get_redirect_url(self):
|
||||
def get_redirect_url(self) -> str:
|
||||
{%- if cookiecutter.username_type == "email" %}
|
||||
return reverse("users:detail", kwargs={"pk": self.request.user.pk})
|
||||
{%- else %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user