-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[django-filter] Absorb django-filter-stubs into typeshed #10919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
58778b5
eb34321
9428022
862b49a
8956aaf
4f00327
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
django_filters.Filter.__init__ | ||
django_filters.FilterMethod | ||
django_filters.FilterSet.base_filters | ||
django_filters.FilterSet.declared_filters | ||
django_filters.NumberFilter.get_max_validator | ||
django_filters.QuerySetRequestMixin | ||
django_filters.RemovedInDjangoFilter25Warning | ||
django_filters.fields.BaseCSVWidget.surrogate | ||
django_filters.fields.CSVWidget.__init__ | ||
django_filters.fields.DJANGO_50 | ||
django_filters.filters.__all__ | ||
django_filters.filters.Filter.__init__ | ||
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.rest_framework.DjangoFilterBackend | ||
django_filters.rest_framework.Filter.__init__ | ||
django_filters.rest_framework.FilterSet.base_filters | ||
django_filters.rest_framework.FilterSet.declared_filters | ||
django_filters.rest_framework.NumberFilter.get_max_validator | ||
django_filters.rest_framework.__all__ | ||
django_filters.rest_framework.backends.DjangoFilterBackend | ||
django_filters.rest_framework.backends.RenameAttributes | ||
django_filters.rest_framework.filters.Filter.__init__ | ||
django_filters.rest_framework.filters.NumberFilter.get_max_validator | ||
django_filters.rest_framework.filterset.FilterSet.base_filters | ||
django_filters.rest_framework.filterset.FilterSet.declared_filters | ||
django_filters.views.BaseFilterView | ||
django_filters.views.FilterMixin | ||
django_filters.views.FilterMixinRenames | ||
django_filters.views.FilterView | ||
django_filters.views.MigrationNotice | ||
django_filters.views.RenameAttributesBase | ||
django_filters.widgets.BaseCSVWidget.surrogate | ||
django_filters.widgets.CSVWidget.__init__ | ||
|
||
# These fail due to DJANGO_SETTINGS_MODULE being unset | ||
django_filters.compat | ||
django_filters.conf | ||
django_filters.utils |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
version = "23.3.*" | ||
upstream_repository = "https://github.com/carltongibson/django-filter" | ||
requires = ["django-stubs"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import Any | ||
|
||
from . import rest_framework as rest_framework | ||
from .filters import * | ||
from .filterset import FilterSet as FilterSet | ||
|
||
def parse_version(version: Any): ... | ||
|
||
VERSION: Any |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
def is_crispy(): ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Any | ||
|
||
from .utils import deprecate as deprecate | ||
|
||
DEFAULTS: Any | ||
DEPRECATED_SETTINGS: Any | ||
|
||
def is_callable(value: Any): ... | ||
|
||
class Settings: | ||
def __getattr__(self, name: Any): ... | ||
def get_setting(self, setting: Any): ... | ||
def change_setting(self, setting: Any, value: Any, enter: Any, **kwargs: Any) -> None: ... | ||
|
||
settings: Any |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from typing import Any | ||
|
||
ALL_FIELDS: str | ||
EMPTY_VALUES: Any |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from typing import Any | ||
|
||
from django.core.exceptions import FieldError | ||
|
||
class FieldLookupError(FieldError): | ||
def __init__(self, model_field: Any, lookup_expr: Any) -> None: ... |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,96 @@ | ||||||
from typing import Any, TypeVar | ||||||
|
||||||
from django import forms | ||||||
from django.db.models import Model | ||||||
|
||||||
from .conf import settings as settings | ||||||
from .constants import EMPTY_VALUES as EMPTY_VALUES | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are lots of re-exports that shouldn't be re-exported. Should I clean these up before initial merge, or in follow-up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. follow-up is fine imo |
||||||
from .utils import handle_timezone as handle_timezone | ||||||
from .widgets import ( | ||||||
BaseCSVWidget as BaseCSVWidget, | ||||||
CSVWidget as CSVWidget, | ||||||
DateRangeWidget as DateRangeWidget, | ||||||
LookupChoiceWidget as LookupChoiceWidget, | ||||||
RangeWidget as RangeWidget, | ||||||
) | ||||||
|
||||||
_M = TypeVar("_M", bound=Model) | ||||||
|
||||||
class RangeField(forms.MultiValueField): | ||||||
widget: Any = ... | ||||||
def __init__(self, fields: Any | None = ..., *args: Any, **kwargs: Any) -> None: ... | ||||||
def compress(self, data_list: Any): ... | ||||||
|
||||||
class DateRangeField(RangeField): | ||||||
widget: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
def compress(self, data_list: Any): ... | ||||||
|
||||||
class DateTimeRangeField(RangeField): | ||||||
widget: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
|
||||||
class IsoDateTimeRangeField(RangeField): | ||||||
widget: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
|
||||||
class TimeRangeField(RangeField): | ||||||
widget: Any = ... | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I clean up attribute assignments?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine to do this in a follow-up imo |
||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
|
||||||
class Lookup: | ||||||
def __new__(cls, value: Any, lookup_expr: Any): ... | ||||||
|
||||||
class LookupChoiceField(forms.MultiValueField): | ||||||
default_error_messages: Any = ... | ||||||
def __init__(self, field: Any, lookup_choices: Any, *args: Any, **kwargs: Any) -> None: ... | ||||||
def compress(self, data_list: Any): ... | ||||||
|
||||||
class IsoDateTimeField(forms.DateTimeField): | ||||||
ISO_8601: str = ... | ||||||
input_formats: Any = ... | ||||||
def strptime(self, value: Any, format: Any): ... | ||||||
|
||||||
class BaseCSVField(forms.Field): | ||||||
base_widget_class: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
def clean(self, value: Any): ... | ||||||
|
||||||
class BaseRangeField(BaseCSVField): | ||||||
widget: Any = ... | ||||||
default_error_messages: Any = ... | ||||||
def clean(self, value: Any): ... | ||||||
|
||||||
class ChoiceIterator: | ||||||
field: Any = ... | ||||||
choices: Any = ... | ||||||
def __init__(self, field: Any, choices: Any) -> None: ... | ||||||
def __iter__(self) -> Any: ... | ||||||
def __len__(self): ... | ||||||
|
||||||
class ModelChoiceIterator(forms.models.ModelChoiceIterator): | ||||||
def __iter__(self) -> Any: ... | ||||||
def __len__(self): ... | ||||||
|
||||||
class ChoiceIteratorMixin: | ||||||
null_label: Any = ... | ||||||
null_value: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
choices: Any = ... | ||||||
|
||||||
class ChoiceField(ChoiceIteratorMixin, forms.ChoiceField): | ||||||
iterator: Any = ... | ||||||
empty_label: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
|
||||||
class MultipleChoiceField(ChoiceIteratorMixin, forms.MultipleChoiceField): | ||||||
iterator: Any = ... | ||||||
empty_label: Any = ... | ||||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||||||
|
||||||
class ModelChoiceField(ChoiceIteratorMixin, forms.ModelChoiceField[_M]): | ||||||
iterator: Any = ... | ||||||
def to_python(self, value: Any): ... | ||||||
|
||||||
class ModelMultipleChoiceField(ChoiceIteratorMixin, forms.ModelMultipleChoiceField[_M]): | ||||||
iterator: Any = ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Callable | ||
from typing import Any | ||
|
||
class Filter: | ||
creation_counter: int = ... | ||
field_class: Any = ... | ||
field_name: Any = ... | ||
lookup_expr: Any = ... | ||
distinct: Any = ... | ||
exclude: Any = ... | ||
extra: Any = ... | ||
def __init__( | ||
self, | ||
field_name: Any | None = ..., | ||
lookup_expr: str = ..., | ||
*, | ||
label: Any | None = ..., | ||
method: Any | None = ..., | ||
distinct: bool = ..., | ||
exclude: bool = ..., | ||
**kwargs: Any, | ||
) -> None: ... | ||
def get_method(self, qs: Any): ... | ||
method: Callable[..., Incomplete] = ... | ||
label: Any = ... | ||
@property | ||
def field(self): ... | ||
def filter(self, qs: Any, value: Any): ... | ||
|
||
class CharFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class BooleanFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class ChoiceFilter(Filter): | ||
field_class: Any = ... | ||
null_value: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
def filter(self, qs: Any, value: Any): ... | ||
|
||
class TypedChoiceFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class UUIDFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class MultipleChoiceFilter(Filter): | ||
field_class: Any = ... | ||
always_filter: bool = ... | ||
conjoined: Any = ... | ||
null_value: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
def is_noop(self, qs: Any, value: Any): ... | ||
def filter(self, qs: Any, value: Any): ... | ||
def get_filter_predicate(self, v: Any): ... | ||
|
||
class TypedMultipleChoiceFilter(MultipleChoiceFilter): | ||
field_class: Any = ... | ||
|
||
class DateFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class DateTimeFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class IsoDateTimeFilter(DateTimeFilter): | ||
field_class: Any = ... | ||
|
||
class TimeFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class DurationFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class QuerySetRequestMixin: | ||
queryset: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
def get_request(self): ... | ||
def get_queryset(self, request: Any): ... | ||
@property | ||
def field(self): ... | ||
|
||
class ModelChoiceFilter(QuerySetRequestMixin, ChoiceFilter): | ||
field_class: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
|
||
class ModelMultipleChoiceFilter(QuerySetRequestMixin, MultipleChoiceFilter): | ||
field_class: Any = ... | ||
|
||
class NumberFilter(Filter): | ||
field_class: Any = ... | ||
|
||
class NumericRangeFilter(Filter): | ||
field_class: Any = ... | ||
lookup_expr: str = ... | ||
def filter(self, qs: Any, value: Any): ... | ||
|
||
class RangeFilter(Filter): | ||
field_class: Any = ... | ||
lookup_expr: str = ... | ||
def filter(self, qs: Any, value: Any): ... | ||
|
||
class DateRangeFilter(ChoiceFilter): | ||
choices: Any = ... | ||
filters: Any = ... | ||
def __init__(self, choices: Any | None = ..., filters: Any | None = ..., *args: Any, **kwargs: Any) -> None: ... | ||
def filter(self, qs: Any, value: Any): ... | ||
|
||
class DateFromToRangeFilter(RangeFilter): | ||
field_class: Any = ... | ||
|
||
class DateTimeFromToRangeFilter(RangeFilter): | ||
field_class: Any = ... | ||
|
||
class IsoDateTimeFromToRangeFilter(RangeFilter): | ||
field_class: Any = ... | ||
|
||
class TimeRangeFilter(RangeFilter): | ||
field_class: Any = ... | ||
|
||
class AllValuesFilter(ChoiceFilter): | ||
@property | ||
def field(self): ... | ||
|
||
class AllValuesMultipleFilter(MultipleChoiceFilter): | ||
@property | ||
def field(self): ... | ||
|
||
class BaseCSVFilter(Filter): | ||
base_field_class: Any = ... | ||
field_class: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
|
||
class BaseInFilter(BaseCSVFilter): | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
|
||
class BaseRangeFilter(BaseCSVFilter): | ||
base_field_class: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
|
||
class LookupChoiceFilter(Filter): | ||
field_class: Any = ... | ||
outer_class: Any = ... | ||
empty_label: Any = ... | ||
lookup_choices: Any = ... | ||
def __init__( | ||
self, field_name: Any | None = ..., lookup_choices: Any | None = ..., field_class: Any | None = ..., **kwargs: Any | ||
) -> None: ... | ||
@classmethod | ||
def normalize_lookup(cls, lookup: Any): ... | ||
def get_lookup_choices(self): ... | ||
@property | ||
def field(self): ... | ||
lookup_expr: Any = ... | ||
def filter(self, qs: Any, lookup: Any): ... | ||
|
||
class OrderingFilter(BaseCSVFilter, ChoiceFilter): | ||
descending_fmt: Any = ... | ||
param_map: Any = ... | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: ... | ||
def get_ordering_value(self, param: Any): ... | ||
def filter(self, qs: Any, value: Any): ... | ||
@classmethod | ||
def normalize_fields(cls, fields: Any): ... | ||
def build_choices(self, fields: Any, labels: Any): ... | ||
|
||
class FilterMethod: | ||
f: Any = ... | ||
def __init__(self, filter_instance: Any) -> None: ... | ||
def __call__(self, qs: Any, value: Any): ... | ||
@property | ||
def method(self): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now believe Any should be used only in places where the type system can't express the precise type. As a result, we'd want a comment with every Any explaining why it's there.
If this is Any merely because you haven't figured out the precise type, you can leave the parameter unannotated, or use
_typeshed.Incomplete
in cases where that's not possible (e.g., for the global below).