From d1c95044d7905bdecff38d935626d24ebceb5636 Mon Sep 17 00:00:00 2001 From: abhiabhi94 <13880786+abhiabhi94@users.noreply.github.com> Date: Tue, 4 Jan 2022 22:03:48 +0530 Subject: [PATCH] Change return type of queryset.bulk_update to int - the change was made in the commit https://github.com/django/django/commit/cd124295d882e13cff556fdeb78e6278d10ac6d5. --- django-stubs/db/models/manager.pyi | 2 +- django-stubs/db/models/query.pyi | 2 +- tests/typecheck/managers/querysets/test_basic_methods.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django-stubs/db/models/manager.pyi b/django-stubs/db/models/manager.pyi index 7a320d2c8..0e02b65da 100644 --- a/django-stubs/db/models/manager.pyi +++ b/django-stubs/db/models/manager.pyi @@ -51,7 +51,7 @@ class BaseManager(Generic[_T]): def bulk_create( self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ... ) -> List[_T]: ... - def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> None: ... + def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> int: ... def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... def update_or_create( self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index 3803eb8ad..a82b1e9d8 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -59,7 +59,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized): def bulk_create( self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ... ) -> List[_T]: ... - def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> None: ... + def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> int: ... def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... def update_or_create( self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any diff --git a/tests/typecheck/managers/querysets/test_basic_methods.yml b/tests/typecheck/managers/querysets/test_basic_methods.yml index 8a8d0780b..ba3bd34f6 100644 --- a/tests/typecheck/managers/querysets/test_basic_methods.yml +++ b/tests/typecheck/managers/querysets/test_basic_methods.yml @@ -30,7 +30,7 @@ reveal_type(qs.count()) # N: Revealed type is "builtins.int" reveal_type(qs.update(created_at=timezone.now())) # N: Revealed type is "builtins.int" reveal_type(qs.in_bulk()) # N: Revealed type is "builtins.dict[Any, myapp.models.Blog*]" - reveal_type(qs.bulk_update(list(qs), fields=["created_at"])) # N: Revealed type is "None" + reveal_type(qs.bulk_update(list(qs), fields=["created_at"])) # N: Revealed type is "builtins.int" reveal_type(qs.bulk_create([])) # N: Revealed type is "builtins.list[myapp.models.Blog*]" reveal_type(qs.delete()) # N: Revealed type is "Tuple[builtins.int, builtins.dict[builtins.str, builtins.int]]" installed_apps: