From 0b46ef2fc83419af42e4cfd1466e6666e6575733 Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Sat, 24 Feb 2024 23:53:57 +0300 Subject: [PATCH] Add QuerySet.(a)update_or_create new create_defaults arg (#1970) --- django-stubs/db/models/manager.pyi | 12 ++++++++++-- django-stubs/db/models/query.pyi | 12 ++++++++++-- scripts/stubtest/allowlist_todo_django50.txt | 6 ------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index d6a58029b..1cfd7b776 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -69,9 +69,17 @@ class BaseManager(Generic[_T]): async def aget_or_create( self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any ) -> tuple[_T, bool]: ... - def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ... + def update_or_create( + self, + defaults: MutableMapping[str, Any] | None = ..., + create_defaults: MutableMapping[str, Any] | None = ..., + **kwargs: Any, + ) -> tuple[_T, bool]: ... async def aupdate_or_create( - self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any + self, + defaults: MutableMapping[str, Any] | None = ..., + create_defaults: MutableMapping[str, Any] | None = ..., + **kwargs: Any, ) -> tuple[_T, bool]: ... def earliest(self, *fields: str | OrderBy) -> _T: ... async def aearliest(self, *fields: str | OrderBy) -> _T: ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index 6f449bf77..3b55ce16c 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -98,9 +98,17 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): async def aget_or_create( self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any ) -> tuple[_T, bool]: ... - def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ... + def update_or_create( + self, + defaults: MutableMapping[str, Any] | None = ..., + create_defaults: MutableMapping[str, Any] | None = ..., + **kwargs: Any, + ) -> tuple[_T, bool]: ... async def aupdate_or_create( - self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any + self, + defaults: MutableMapping[str, Any] | None = ..., + create_defaults: MutableMapping[str, Any] | None = ..., + **kwargs: Any, ) -> tuple[_T, bool]: ... def earliest(self, *fields: str | OrderBy) -> _Row: ... async def aearliest(self, *fields: str | OrderBy) -> _Row: ... diff --git a/scripts/stubtest/allowlist_todo_django50.txt b/scripts/stubtest/allowlist_todo_django50.txt index c7893109e..22fc052d5 100644 --- a/scripts/stubtest/allowlist_todo_django50.txt +++ b/scripts/stubtest/allowlist_todo_django50.txt @@ -66,8 +66,6 @@ django.contrib.gis.db.models.Func.allowed_default django.contrib.gis.db.models.Lookup.allowed_default django.contrib.gis.db.models.Prefetch.get_current_querysets django.contrib.gis.db.models.Q.identity -django.contrib.gis.db.models.QuerySet.aupdate_or_create -django.contrib.gis.db.models.QuerySet.update_or_create django.contrib.gis.db.models.Value.allowed_default django.contrib.gis.db.models.When.allowed_default django.contrib.gis.db.models.functions.ClosestPoint @@ -174,8 +172,6 @@ django.db.models.Func.allowed_default django.db.models.Lookup.allowed_default django.db.models.Prefetch.get_current_querysets django.db.models.Q.identity -django.db.models.QuerySet.aupdate_or_create -django.db.models.QuerySet.update_or_create django.db.models.Value.allowed_default django.db.models.When.allowed_default django.db.models.constraints.BaseConstraint.__init__ @@ -214,8 +210,6 @@ django.db.models.lookups.IntegerLessThan.overflow_exception django.db.models.lookups.IntegerLessThanOrEqual django.db.models.lookups.Lookup.allowed_default django.db.models.query.Prefetch.get_current_querysets -django.db.models.query.QuerySet.aupdate_or_create -django.db.models.query.QuerySet.update_or_create django.db.models.query_utils.FilteredRelation.relabeled_clone django.db.models.query_utils.FilteredRelation.resolve_expression django.db.models.query_utils.Q.identity