From 3a9263dc62d2b426b7da7f8e3e9b5d8a70db476a Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Tue, 12 Nov 2019 11:31:24 +0100 Subject: [PATCH] Two small improvements (#217) * Add return type for admin.SimpleListFilter.lookups * force_login() can take any user, not just builtin --- django-stubs/contrib/admin/filters.pyi | 2 +- django-stubs/test/client.pyi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django-stubs/contrib/admin/filters.pyi b/django-stubs/contrib/admin/filters.pyi index 80d6109..3cba3ad 100644 --- a/django-stubs/contrib/admin/filters.pyi +++ b/django-stubs/contrib/admin/filters.pyi @@ -24,7 +24,7 @@ class SimpleListFilter(ListFilter): parameter_name: Any = ... lookup_choices: Any = ... def value(self) -> Optional[str]: ... - def lookups(self, request: Any, model_admin: Any) -> None: ... + def lookups(self, request: Any, model_admin: Any) -> List[Tuple[Any, str]]: ... class FieldListFilter(ListFilter): field: Field = ... diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index d8853d0..e3cb3fd 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -1,7 +1,7 @@ from io import BytesIO from typing import Any, Dict, List, Optional, Pattern, Tuple, Type, Union -from django.contrib.auth.models import User +from django.contrib.auth.models import AbstractUser from django.contrib.sessions.backends.base import SessionBase from django.core.handlers.base import BaseHandler from django.core.serializers.json import DjangoJSONEncoder @@ -113,7 +113,7 @@ class Client: @property def session(self) -> SessionBase: ... def login(self, **credentials: Any) -> bool: ... - def force_login(self, user: User, backend: Optional[str] = ...) -> None: ... + def force_login(self, user: AbstractUser, backend: Optional[str] = ...) -> None: ... def logout(self) -> None: ... def conditional_content_removal(request: HttpRequest, response: HttpResponseBase) -> HttpResponse: ...