Skip to content

Commit

Permalink
Applied Black.
Browse files Browse the repository at this point in the history
  • Loading branch information
carltongibson committed Jun 17, 2022
1 parent ab35490 commit f4866a9
Show file tree
Hide file tree
Showing 38 changed files with 3,259 additions and 2,824 deletions.
11 changes: 6 additions & 5 deletions django_filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

# We make the `rest_framework` module available without an additional import.
# If DRF is not installed, no-op.
if pkgutil.find_loader('rest_framework') is not None:
if pkgutil.find_loader("rest_framework") is not None:
from . import rest_framework
del pkgutil

__version__ = '22.1'
__version__ = "22.1"


def parse_version(version):
'''
"""
'0.1.2.dev1' -> (0, 1, 2, 'dev1')
'0.1.2' -> (0, 1, 2)
'''
v = version.split('.')
"""
v = version.split(".")
ret = []
for p in v:
if p.isdigit():
Expand All @@ -27,4 +27,5 @@ def parse_version(version):
ret.append(p)
return tuple(ret)


VERSION = parse_version(__version__)
2 changes: 1 addition & 1 deletion django_filters/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def is_crispy():
return 'crispy_forms' in settings.INSTALLED_APPS and crispy_forms
return "crispy_forms" in settings.INSTALLED_APPS and crispy_forms


# coreapi is optional (Note that uritemplate is a dependency of coreapi)
Expand Down
89 changes: 41 additions & 48 deletions django_filters/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,53 @@
from .utils import deprecate

DEFAULTS = {
'DISABLE_HELP_TEXT': False,

'DEFAULT_LOOKUP_EXPR': 'exact',

"DISABLE_HELP_TEXT": False,
"DEFAULT_LOOKUP_EXPR": "exact",
# empty/null choices
'EMPTY_CHOICE_LABEL': '---------',
'NULL_CHOICE_LABEL': None,
'NULL_CHOICE_VALUE': 'null',

'VERBOSE_LOOKUPS': {
"EMPTY_CHOICE_LABEL": "---------",
"NULL_CHOICE_LABEL": None,
"NULL_CHOICE_VALUE": "null",
"VERBOSE_LOOKUPS": {
# transforms don't need to be verbose, since their expressions are chained
'date': _('date'),
'year': _('year'),
'month': _('month'),
'day': _('day'),
'week_day': _('week day'),
'hour': _('hour'),
'minute': _('minute'),
'second': _('second'),

"date": _("date"),
"year": _("year"),
"month": _("month"),
"day": _("day"),
"week_day": _("week day"),
"hour": _("hour"),
"minute": _("minute"),
"second": _("second"),
# standard lookups
'exact': '',
'iexact': '',
'contains': _('contains'),
'icontains': _('contains'),
'in': _('is in'),
'gt': _('is greater than'),
'gte': _('is greater than or equal to'),
'lt': _('is less than'),
'lte': _('is less than or equal to'),
'startswith': _('starts with'),
'istartswith': _('starts with'),
'endswith': _('ends with'),
'iendswith': _('ends with'),
'range': _('is in range'),
'isnull': _('is null'),
'regex': _('matches regex'),
'iregex': _('matches regex'),
'search': _('search'),

"exact": "",
"iexact": "",
"contains": _("contains"),
"icontains": _("contains"),
"in": _("is in"),
"gt": _("is greater than"),
"gte": _("is greater than or equal to"),
"lt": _("is less than"),
"lte": _("is less than or equal to"),
"startswith": _("starts with"),
"istartswith": _("starts with"),
"endswith": _("ends with"),
"iendswith": _("ends with"),
"range": _("is in range"),
"isnull": _("is null"),
"regex": _("matches regex"),
"iregex": _("matches regex"),
"search": _("search"),
# postgres lookups
'contained_by': _('is contained by'),
'overlap': _('overlaps'),
'has_key': _('has key'),
'has_keys': _('has keys'),
'has_any_keys': _('has any keys'),
'trigram_similar': _('search'),
"contained_by": _("is contained by"),
"overlap": _("overlaps"),
"has_key": _("has key"),
"has_keys": _("has keys"),
"has_any_keys": _("has any keys"),
"trigram_similar": _("search"),
},
}


DEPRECATED_SETTINGS = [
]
DEPRECATED_SETTINGS = []


def is_callable(value):
Expand All @@ -66,7 +60,6 @@ def is_callable(value):


class Settings:

def __getattr__(self, name):
if name not in DEFAULTS:
msg = "'%s' object has no attribute '%s'"
Expand All @@ -82,15 +75,15 @@ def __getattr__(self, name):
return value

def get_setting(self, setting):
django_setting = 'FILTERS_%s' % setting
django_setting = "FILTERS_%s" % setting

if setting in DEPRECATED_SETTINGS and hasattr(dj_settings, django_setting):
deprecate("The '%s' setting has been deprecated." % django_setting)

return getattr(dj_settings, django_setting, DEFAULTS[setting])

def change_setting(self, setting, value, enter, **kwargs):
if not setting.startswith('FILTERS_'):
if not setting.startswith("FILTERS_"):
return
setting = setting[8:] # strip 'FILTERS_'

Expand Down
5 changes: 2 additions & 3 deletions django_filters/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ALL_FIELDS = "__all__"

ALL_FIELDS = '__all__'


EMPTY_VALUES = ([], (), {}, '', None)
EMPTY_VALUES = ([], (), {}, "", None)
1 change: 0 additions & 1 deletion django_filters/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.core.exceptions import FieldError


Expand Down
Loading

0 comments on commit f4866a9

Please sign in to comment.