From e8b70e47522cd3a583d183d7976773351dfe8a8b Mon Sep 17 00:00:00 2001 From: Thiago Bellini Ribeiro Date: Sat, 5 Oct 2024 14:57:48 -0300 Subject: [PATCH] fix: Check permissions methods expects any model, not a user model only --- django-stubs/contrib/auth/models.pyi | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/django-stubs/contrib/auth/models.pyi b/django-stubs/contrib/auth/models.pyi index 5d101ded2..a72273a27 100644 --- a/django-stubs/contrib/auth/models.pyi +++ b/django-stubs/contrib/auth/models.pyi @@ -56,14 +56,14 @@ class UserManager(BaseUserManager[_T]): username: str, email: str | None = ..., password: str | None = ..., - **extra_fields: Any + **extra_fields: Any, ) -> _T: ... def create_superuser( self, username: str, email: str | None, password: str | None, - **extra_fields: Any + **extra_fields: Any, ) -> _T: ... def with_perm( self, @@ -78,13 +78,11 @@ class PermissionsMixin(models.Model): is_superuser = models.BooleanField() groups = models.ManyToManyField[Group, Any](Group) user_permissions = models.ManyToManyField[Permission, Any](Permission) - def get_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... - def get_group_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... - def get_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ... - def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ... - def has_perms( - self, perm_list: Iterable[str], obj: _AnyUser | None = ... - ) -> bool: ... + def get_user_permissions(self, obj: Model | None = ...) -> set[str]: ... + def get_group_permissions(self, obj: Model | None = ...) -> set[str]: ... + def get_all_permissions(self, obj: Model | None = ...) -> set[str]: ... + def has_perm(self, perm: str, obj: Model | None = ...) -> bool: ... + def has_perms(self, perm_list: Iterable[str], obj: Model | None = ...) -> bool: ... def has_module_perms(self, app_label: str) -> bool: ... class AbstractUser(AbstractBaseUser, PermissionsMixin):