Skip to content

Commit

Permalink
Update contrib.admin.models.LogEntryManager (#2423)
Browse files Browse the repository at this point in the history
* Update django.contrib.admin.models.LogEntryManager

Signed-off-by: SaJH <wogur981208@gmail.com>

* Add overload decorator for log_actions to clarify return types

Signed-off-by: SaJH <wogur981208@gmail.com>

---------

Signed-off-by: SaJH <wogur981208@gmail.com>
  • Loading branch information
JaeHyuckSa authored Dec 7, 2024
1 parent ea16b44 commit 9d6c8f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 22 additions & 1 deletion django-stubs/contrib/admin/models.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Any, ClassVar
from typing import Any, ClassVar, Literal, overload
from uuid import UUID

from django.db import models
from django.db.models import QuerySet
from django.db.models.base import Model
from typing_extensions import deprecated

Expand All @@ -21,6 +22,26 @@ class LogEntryManager(models.Manager[LogEntry]):
action_flag: int,
change_message: Any = ...,
) -> LogEntry: ...
@overload
def log_actions(
self,
user_id: int,
queryset: QuerySet[Model],
action_flag: int,
change_message: str | list[Any] = "",
*,
single_object: Literal[True],
) -> LogEntry: ...
@overload
def log_actions(
self,
user_id: int,
queryset: QuerySet[Model],
action_flag: int,
change_message: str | list[Any] = "",
*,
single_object: Literal[False] = False,
) -> list[LogEntry]: ...

class LogEntry(models.Model):
action_time: models.DateTimeField
Expand Down
1 change: 0 additions & 1 deletion scripts/stubtest/allowlist_todo_django51.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

django.contrib.admin.helpers.Fieldset.is_collapsible
django.contrib.admin.helpers.InlineAdminFormSet.is_collapsible
django.contrib.admin.models.LogEntryManager.log_actions
django.contrib.auth.base_user.BaseUserManager.make_random_password
django.contrib.auth.checks.check_middleware
django.contrib.auth.forms.AdminPasswordChangeForm.clean_password2
Expand Down

0 comments on commit 9d6c8f4

Please sign in to comment.