Skip to content

Commit 6b31bed

Browse files
author
Mark Gregson
authored
Formset get_queryset() returns QuerySet (#2174)
1 parent b8f1592 commit 6b31bed

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

django-stubs/forms/models.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ from django.forms.renderers import BaseRenderer
1515
from django.forms.utils import ErrorList, _DataT, _FilesT
1616
from django.forms.widgets import Widget
1717
from django.utils.choices import BaseChoiceIterator, CallableChoiceIterator, _Choices, _ChoicesCallable
18-
from django.utils.datastructures import _IndexableCollection, _PropertyDescriptor
18+
from django.utils.datastructures import _PropertyDescriptor
1919
from django.utils.functional import _StrOrPromise
2020
from typing_extensions import TypeAlias
2121

@@ -126,7 +126,7 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]):
126126
**kwargs: Any,
127127
) -> None: ...
128128
def initial_form_count(self) -> int: ...
129-
def get_queryset(self) -> _IndexableCollection[_M]: ...
129+
def get_queryset(self) -> QuerySet[_M]: ...
130130
def save_new(self, form: _ModelFormT, commit: bool = ...) -> _M: ...
131131
def save_existing(self, form: _ModelFormT, obj: _M, commit: bool = ...) -> _M: ...
132132
def delete_existing(self, obj: _M, commit: bool = ...) -> None: ...

tests/typecheck/test_formsets.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ArticleFS(instance=Article()) # E: Argument "instance" to "BaseInlineFormSet" has incompatible type "Article"; expected "Optional[Category]" [arg-type]
88
fs = ArticleFS(instance=Category())
99
reveal_type(fs.instance) # N: Revealed type is "myapp.models.Category"
10+
reveal_type(fs.get_queryset()) # N: Revealed type is "django.db.models.query.QuerySet[myapp.models.Article, myapp.models.Article]"
1011
installed_apps:
1112
- myapp
1213
files:

0 commit comments

Comments
 (0)