Skip to content

Commit 2ded950

Browse files
authored
Allow permission methods to take any model instance as obj (#2640)
1 parent 6917033 commit 2ded950

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

django-stubs/contrib/auth/models.pyi

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ class PermissionsMixin(models.Model):
7979
groups = models.ManyToManyField(Group)
8080
user_permissions = models.ManyToManyField(Permission)
8181

82-
def get_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
83-
async def aget_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
84-
def get_group_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
85-
async def aget_group_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
86-
def get_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
87-
async def aget_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
88-
def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ...
89-
async def ahas_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ...
90-
def has_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ...
91-
async def ahas_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ...
82+
def get_user_permissions(self, obj: Model | None = ...) -> set[str]: ...
83+
async def aget_user_permissions(self, obj: Model | None = ...) -> set[str]: ...
84+
def get_group_permissions(self, obj: Model | None = ...) -> set[str]: ...
85+
async def aget_group_permissions(self, obj: Model | None = ...) -> set[str]: ...
86+
def get_all_permissions(self, obj: Model | None = ...) -> set[str]: ...
87+
async def aget_all_permissions(self, obj: Model | None = ...) -> set[str]: ...
88+
def has_perm(self, perm: str, obj: Model | None = ...) -> bool: ...
89+
async def ahas_perm(self, perm: str, obj: Model | None = ...) -> bool: ...
90+
def has_perms(self, perm_list: Iterable[str], obj: Model | None = ...) -> bool: ...
91+
async def ahas_perms(self, perm_list: Iterable[str], obj: Model | None = ...) -> bool: ...
9292
def has_module_perms(self, app_label: str) -> bool: ...
9393
async def ahas_module_perms(self, app_label: str) -> bool: ...
9494

@@ -131,16 +131,16 @@ class AnonymousUser:
131131
def groups(self) -> EmptyManager[Group]: ...
132132
@property
133133
def user_permissions(self) -> EmptyManager[Permission]: ...
134-
def get_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
135-
async def aget_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
136-
def get_group_permissions(self, obj: _AnyUser | None = ...) -> set[Any]: ...
137-
async def aget_group_permissions(self, obj: _AnyUser | None = ...) -> set[Any]: ...
138-
def get_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
139-
async def aget_all_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
140-
def has_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ...
141-
async def ahas_perm(self, perm: str, obj: _AnyUser | None = ...) -> bool: ...
142-
def has_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ...
143-
async def ahas_perms(self, perm_list: Iterable[str], obj: _AnyUser | None = ...) -> bool: ...
134+
def get_user_permissions(self, obj: Model | None = ...) -> set[str]: ...
135+
async def aget_user_permissions(self, obj: Model | None = ...) -> set[str]: ...
136+
def get_group_permissions(self, obj: Model | None = ...) -> set[Any]: ...
137+
async def aget_group_permissions(self, obj: Model | None = ...) -> set[Any]: ...
138+
def get_all_permissions(self, obj: Model | None = ...) -> set[str]: ...
139+
async def aget_all_permissions(self, obj: Model | None = ...) -> set[str]: ...
140+
def has_perm(self, perm: str, obj: Model | None = ...) -> bool: ...
141+
async def ahas_perm(self, perm: str, obj: Model | None = ...) -> bool: ...
142+
def has_perms(self, perm_list: Iterable[str], obj: Model | None = ...) -> bool: ...
143+
async def ahas_perms(self, perm_list: Iterable[str], obj: Model | None = ...) -> bool: ...
144144
def has_module_perms(self, module: str) -> bool: ...
145145
async def ahas_module_perms(self, module: str) -> bool: ...
146146
@property

0 commit comments

Comments
 (0)