Skip to content

Commit

Permalink
Setup initial structure
Browse files Browse the repository at this point in the history
- Create the barebones requirements for the repository
- Install development requirements
- Setup CI
  • Loading branch information
DavisRayM committed Jan 30, 2020
0 parents commit 9b4fa2c
Show file tree
Hide file tree
Showing 27 changed files with 1,184 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.egg-info
__pycache__/
.pytest_cache/
.mypy_cache/
.vscode/
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
sudo: required
dist: xenial
language: python
jobs:
include:
- name: Test against Python 3.6
python: 3.6
script: pytest

- name: Test against Python 3.7
python: 3.7
script: pytest

- name: Lint test with black
python: 3.6
script: black --check django_filters-stubs/

- name: Lint test with isort
python: 3.6
script: isort --check

- name: Lint test with flake8
python: 3.6
script: flake8

before_install:
- pip install --upgrade pip
- pip install pipenv
install:
- pipenv install --dev
7 changes: 7 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 Davis Raymond Muro.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 changes: 16 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "==19.10b0"
flake8 = "*"
isort = "*"
pytest-mypy-plugins = "*"

[packages]
django-filter-stubs = {editable = true,path = "."}

[requires]
python_version = "3.7"
403 changes: 403 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# PEP-484 Stubs for django-filter ::: Beta

[![Build Status](https://travis-ci.org/DavisRayM/django-filter-stubs.svg?branch=master)](https://travis-ci.org/DavisRayM/django-filter-stubs)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)

This package contains type subs to provide more precise static types for Django Filters.

## Installation

```bash
pip install django-filter-stubs
```
9 changes: 9 additions & 0 deletions django_filters-stubs/__init__.pyi
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
1 change: 1 addition & 0 deletions django_filters-stubs/compat.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def is_crispy(): ...
17 changes: 17 additions & 0 deletions django_filters-stubs/conf.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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
4 changes: 4 additions & 0 deletions django_filters-stubs/constants.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import Any

ALL_FIELDS: str
EMPTY_VALUES: Any
6 changes: 6 additions & 0 deletions django_filters-stubs/exceptions.pyi
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: ...
95 changes: 95 additions & 0 deletions django_filters-stubs/fields.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from typing import Any, Optional

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
from .widgets import CSVWidget as CSVWidget
from .widgets import DateRangeWidget as DateRangeWidget
from .widgets import LookupChoiceWidget as LookupChoiceWidget
from .widgets import RangeWidget as RangeWidget

class RangeField(forms.MultiValueField):
widget: Any = ...
def __init__(
self, fields: Optional[Any] = ..., *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 = ...
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 = ...
182 changes: 182 additions & 0 deletions django_filters-stubs/filters.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
from typing import Any, Callable, Optional

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: Optional[Any] = ...,
lookup_expr: str = ...,
*,
label: Optional[Any] = ...,
method: Optional[Any] = ...,
distinct: bool = ...,
exclude: bool = ...,
**kwargs: Any
) -> None: ...
def get_method(self, qs: Any): ...
method: Callable = ...
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: Optional[Any] = ...,
filters: Optional[Any] = ...,
*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: Optional[Any] = ...,
lookup_choices: Optional[Any] = ...,
field_class: Optional[Any] = ...,
**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): ...
Loading

0 comments on commit 9b4fa2c

Please sign in to comment.