diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 307a259b2..fab91bc9a 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -15,7 +15,7 @@ from django.forms.renderers import BaseRenderer from django.forms.utils import ErrorList, _DataT, _FilesT from django.forms.widgets import Widget from django.utils.choices import BaseChoiceIterator, CallableChoiceIterator, _Choices, _ChoicesCallable -from django.utils.datastructures import _IndexableCollection, _PropertyDescriptor +from django.utils.datastructures import _PropertyDescriptor from django.utils.functional import _StrOrPromise from typing_extensions import TypeAlias @@ -126,7 +126,7 @@ class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]): **kwargs: Any, ) -> None: ... def initial_form_count(self) -> int: ... - def get_queryset(self) -> _IndexableCollection[_M]: ... + def get_queryset(self) -> QuerySet[_M]: ... def save_new(self, form: _ModelFormT, commit: bool = ...) -> _M: ... def save_existing(self, form: _ModelFormT, obj: _M, commit: bool = ...) -> _M: ... def delete_existing(self, obj: _M, commit: bool = ...) -> None: ... diff --git a/tests/typecheck/test_formsets.yml b/tests/typecheck/test_formsets.yml index 3a092f324..d7cc35a7c 100644 --- a/tests/typecheck/test_formsets.yml +++ b/tests/typecheck/test_formsets.yml @@ -7,6 +7,7 @@ ArticleFS(instance=Article()) # E: Argument "instance" to "BaseInlineFormSet" has incompatible type "Article"; expected "Optional[Category]" [arg-type] fs = ArticleFS(instance=Category()) reveal_type(fs.instance) # N: Revealed type is "myapp.models.Category" + reveal_type(fs.get_queryset()) # N: Revealed type is "django.db.models.query.QuerySet[myapp.models.Article, myapp.models.Article]" installed_apps: - myapp files: