apply black formatting

This commit is contained in:
Jason Kraus 2019-06-17 11:39:21 -07:00
parent 4ba3b544c9
commit 6d5cfee94f
2 changed files with 14 additions and 10 deletions

View File

@ -30,22 +30,26 @@ singledispatch = import_single_dispatch()
def _is_dunder(name): def _is_dunder(name):
"""Returns True if a __dunder__ name, False otherwise.""" """Returns True if a __dunder__ name, False otherwise."""
return (len(name) > 4 and return (
name[:2] == name[-2:] == '__' and len(name) > 4
name[2:3] != '_' and and name[:2] == name[-2:] == "__"
name[-3:-2] != '_') and name[2:3] != "_"
and name[-3:-2] != "_"
)
def _is_sunder(name): def _is_sunder(name):
"""Returns True if a _sunder_ name, False otherwise.""" """Returns True if a _sunder_ name, False otherwise."""
return (len(name) > 2 and return (
name[0] == name[-1] == '_' and len(name) > 2
name[1:2] != '_' and and name[0] == name[-1] == "_"
name[-2:-1] != '_') and name[1:2] != "_"
and name[-2:-1] != "_"
)
def convert_choice_name(name): def convert_choice_name(name):
name = force_text(name).encode('utf8').decode('ascii', 'ignore') name = force_text(name).encode("utf8").decode("ascii", "ignore")
name = to_const(name) name = to_const(name)
if _is_sunder(name) or _is_dunder(name): if _is_sunder(name) or _is_dunder(name):
name = "A%s" % name name = "A%s" % name

View File

@ -4,7 +4,7 @@ from __future__ import absolute_import
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
CHOICES = ((1, u"1: this漢"), (2, _(u"2: that漢")), (u'_3漢', "__amount__")) CHOICES = ((1, u"1: this漢"), (2, _(u"2: that漢")), (u"_3漢", "__amount__"))
class Pet(models.Model): class Pet(models.Model):