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

fix: UserAdmin accepts AbstractUser #1783

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions django-stubs/contrib/auth/admin.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from typing import Any
from typing import Any, Generic, TypeVar

Choose a reason for hiding this comment

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

Suggested change
from typing import Any, Generic, TypeVar
from typing import Any, TypeVar

As per below comments, I do not think this is needed.


from django.contrib import admin
from django.contrib.auth.models import Group, User
from django.contrib.auth.models import AbstractUser, Group
from django.http.request import HttpRequest
from django.http.response import HttpResponse

csrf_protect_m: Any
sensitive_post_parameters_m: Any
_M = TypeVar("_M", bound=AbstractUser, covariant=False)

Choose a reason for hiding this comment

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

Suggested change
_M = TypeVar("_M", bound=AbstractUser, covariant=False)
_M = TypeVar("_M", bound=AbstractUser)

covariant is False by default I think.


class GroupAdmin(admin.ModelAdmin[Group]): ...

class UserAdmin(admin.ModelAdmin[User]):
class UserAdmin(admin.ModelAdmin[_M], Generic[_M]):

Choose a reason for hiding this comment

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

Suggested change
class UserAdmin(admin.ModelAdmin[_M], Generic[_M]):
class UserAdmin(admin.ModelAdmin[_M]):

I do not think the Generic is needed.

change_user_password_template: Any
add_fieldsets: Any
add_form: Any
Expand Down