From 1e34eaa0311a331487283936b1cab8dbcf8c4777 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Sun, 22 Oct 2023 12:52:25 +0300 Subject: [PATCH] [django-filter] Various fixes --- stubs/django-filter/@tests/stubtest_allowlist.txt | 1 - stubs/django-filter/django_filters/filters.pyi | 6 ++++-- stubs/django-filter/django_filters/models.pyi | 0 stubs/django-filter/django_filters/views.pyi | 3 ++- stubs/django-filter/django_filters/widgets.pyi | 12 +++++++++--- 5 files changed, 15 insertions(+), 7 deletions(-) delete mode 100644 stubs/django-filter/django_filters/models.pyi diff --git a/stubs/django-filter/@tests/stubtest_allowlist.txt b/stubs/django-filter/@tests/stubtest_allowlist.txt index acb8744c4c48..93d884d2990a 100644 --- a/stubs/django-filter/@tests/stubtest_allowlist.txt +++ b/stubs/django-filter/@tests/stubtest_allowlist.txt @@ -13,7 +13,6 @@ django_filters.filters.NumberFilter.get_max_validator django_filters.filterset.BaseFilterSet.filter_for_field django_filters.filterset.FilterSet.base_filters django_filters.filterset.FilterSet.declared_filters -django_filters.models django_filters.rest_framework.DjangoFilterBackend django_filters.rest_framework.Filter.__init__ django_filters.rest_framework.FilterSet.base_filters diff --git a/stubs/django-filter/django_filters/filters.pyi b/stubs/django-filter/django_filters/filters.pyi index 10697beb231e..db363f11da0e 100644 --- a/stubs/django-filter/django_filters/filters.pyi +++ b/stubs/django-filter/django_filters/filters.pyi @@ -1,4 +1,6 @@ -from typing import Any, Callable +from _typeshed import Incomplete +from collections.abc import Callable +from typing import Any class Filter: creation_counter: int = ... @@ -20,7 +22,7 @@ class Filter: **kwargs: Any, ) -> None: ... def get_method(self, qs: Any): ... - method: Callable = ... + method: Callable[..., Incomplete] = ... label: Any = ... @property def field(self): ... diff --git a/stubs/django-filter/django_filters/models.pyi b/stubs/django-filter/django_filters/models.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stubs/django-filter/django_filters/views.pyi b/stubs/django-filter/django_filters/views.pyi index 482056c8029f..fc36dcf123ea 100644 --- a/stubs/django-filter/django_filters/views.pyi +++ b/stubs/django-filter/django_filters/views.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from typing import Any from django.views.generic import View @@ -19,7 +20,7 @@ class FilterMixin(metaclass=FilterMixinRenames): def get_filterset_kwargs(self, filterset_class: Any): ... def get_strict(self): ... -class BaseFilterView(FilterMixin, MultipleObjectMixin, View): +class BaseFilterView(FilterMixin, MultipleObjectMixin[Incomplete], View): filterset: Any = ... object_list: Any = ... def get(self, request: Any, *args: Any, **kwargs: Any): ... diff --git a/stubs/django-filter/django_filters/widgets.pyi b/stubs/django-filter/django_filters/widgets.pyi index 2e9f387944e5..96de761b1353 100644 --- a/stubs/django-filter/django_filters/widgets.pyi +++ b/stubs/django-filter/django_filters/widgets.pyi @@ -1,10 +1,11 @@ -from typing import Any +from _typeshed import Incomplete +from typing import Any, TypeAlias from django import forms from django.forms.renderers import BaseRenderer from django.utils.safestring import SafeText -_OptAttrs = dict[str, Any] +_OptAttrs: TypeAlias = dict[str, Any] class LinkWidget(forms.Widget): choices: Any = ... @@ -12,7 +13,12 @@ class LinkWidget(forms.Widget): data: Any = ... def value_from_datadict(self, data: Any, files: Any, name: Any): ... def render( # type: ignore[override] - self, name: str, value: Any, attrs: _OptAttrs | None = ..., choices: tuple = ..., renderer: BaseRenderer | None = ... + self, + name: str, + value: Any, + attrs: _OptAttrs | None = ..., + choices: tuple[Incomplete, ...] = ..., + renderer: BaseRenderer | None = ..., ) -> SafeText: ... def render_options(self, choices: Any, selected_choices: Any, name: Any): ... def render_option(self, name: Any, selected_choices: Any, option_value: Any, option_label: Any): ...