-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[django-filter] Absorb django-filter-stubs into typeshed #10919
Open
intgr
wants to merge
8
commits into
python:main
Choose a base branch
from
intgr:add-types-django-filter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+670
−0
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
19df4ea
[django-filter] Setup initial structure
DavisRayM b05212f
[django-filter] Fix widget error
palfrey 6977474
[django-filter] Explicitly export all the filters from the rest_frame…
palfrey dd1ff42
[django-filter] Update to typeshed style
intgr feb91c9
[django-filter] Add django-filter metadata
intgr 63e9ab6
[django-filter] Various minor fixes
intgr 8044a38
Merge branch 'main' into add-types-django-filter
srittau af43718
Merge branch 'main' into add-types-django-filter
JelleZijlstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", "djangorestframework-stubs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
def is_crispy(): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from typing import Any | ||
|
||
ALL_FIELDS: str | ||
EMPTY_VALUES: Any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,93 @@ | ||||||
from typing import Any | ||||||
|
||||||
from django import forms | ||||||
|
||||||
from .conf import settings as settings | ||||||
from .constants import EMPTY_VALUES as EMPTY_VALUES | ||||||
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, | ||||||
) | ||||||
|
||||||
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): | ||||||
iterator: Any = ... | ||||||
def to_python(self, value: Any): ... | ||||||
|
||||||
class ModelMultipleChoiceField(ChoiceIteratorMixin, forms.ModelMultipleChoiceField): | ||||||
iterator: Any = ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): ... |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
follow-up is fine imo