Skip to content

Commit f2412cf

Browse files
Johan Lübckeboxed
authored andcommitted
Project green
1 parent 1a35a54 commit f2412cf

32 files changed

+212
-144
lines changed

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def reset_sequences(request, django_db_blocker):
4848
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
4949
for i, (table,) in enumerate(cursor.fetchall()):
5050
cursor.execute(f"""
51-
INSERT INTO SQLITE_SEQUENCE (name,seq) SELECT '{table}', {(i + 1) * 1000} WHERE NOT EXISTS
51+
INSERT INTO SQLITE_SEQUENCE (name,seq) SELECT '{table}', {(i + 1) * 1000} WHERE NOT EXISTS
5252
(SELECT changes() AS change FROM sqlite_sequence WHERE change <> 0);
5353
""")
5454

examples/examples/form_examples.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ class MyForm(Form):
113113

114114
@example(gettext("Custom actions can be added to forms"))
115115
def form_example_6(request):
116-
do_nothing = lambda **_: None
116+
@staticmethod
117+
def do_nothing(**_):
118+
return None
119+
117120
return Form.edit(
118121
auto__instance=Artist.objects.all().first(),
119122
actions=dict(

examples/examples/supernaut.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ class AlbumTable(Table):
5555
class Meta:
5656
auto__model = Album
5757
page_size = 20
58-
columns__name__cell__url = lambda row, **_: row.get_absolute_url()
58+
59+
@staticmethod
60+
def columns__name__cell__url(row, **_):
61+
return row.get_absolute_url()
62+
5963
columns__name__filter__include = True
6064
columns__year__filter__include = True
6165
columns__year__filter__field__include = False
@@ -72,7 +76,11 @@ class Meta:
7276
class ArtistTable(Table):
7377
class Meta:
7478
auto__model = Artist
75-
columns__name__cell__url = lambda row, **_: row.get_absolute_url()
79+
80+
@staticmethod
81+
def columns__name__cell__url(row, **_):
82+
return row.get_absolute_url()
83+
7684
columns__name__filter__include = True
7785

7886

examples/examples/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ def get_absolute_url():
239239
class ShortcutSelectorForm(Form):
240240
class Meta:
241241
attrs__method = 'get'
242-
actions__submit__post_handler = lambda **_: None
242+
243+
@staticmethod
244+
def actions__submit__post_handler(**_):
245+
return None
243246

244247
shortcut = Field.multi_choice(
245248
choices=[

iommi/_web_compat.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
from django.conf import settings
12
from django.core.exceptions import (
23
ImproperlyConfigured,
4+
ValidationError, # noqa: F401
35
)
6+
from django.core.validators import URLValidator, validate_email # noqa: F401
47
from django.http import (
8+
HttpRequest, # noqa: F401
9+
HttpResponse, # noqa: F401
10+
HttpResponseRedirect, # noqa: F401
511
QueryDict, # noqa: F401
612
)
13+
from django.http.response import HttpResponseBase # noqa: F401
14+
from django.shortcuts import render # noqa: F401
715
from django.template import RequestContext
816
from django.template.backends.django import Template as DjangoLoadedTemplate
917
from django.template.context_processors import csrf as csrf_
@@ -13,13 +21,14 @@
1321
render_to_string,
1422
)
1523
from django.template.utils import InvalidTemplateEngineError
24+
from django.utils.encoding import smart_str # noqa: F401
1625
from django.utils.html import format_html as django_format_html
1726
from django.utils.safestring import mark_safe
27+
from django.utils.text import slugify # noqa: F401
1828

1929
DjangoTemplate = None
2030
JinjaTemplate = None
2131

22-
from django.conf import settings
2332

2433
template_types = tuple()
2534

@@ -48,7 +57,7 @@ class Template:
4857
def __init__(self, template_string):
4958
self.s = template_string
5059

51-
def render(self, context):
60+
def render(self, context): # noqa: F811
5261
if DjangoTemplate is not None:
5362
return DjangoTemplate(self.s).render(context=context)
5463
else:

iommi/_web_compat_flask.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ def __init__(self, environ):
55
self.r = Request(environ)
66

77
@property
8-
def POST(self):
8+
def POST(self): # noqa: N802
99
return self.r.form
1010

1111
@property
12-
def GET(self):
12+
def GET(self): # noqa: N802
1313
return self.r.args
1414

1515
@property
1616
def method(self):
1717
return self.r.method
1818

1919
@property
20-
def META(self):
20+
def META(self): # noqa: N802
2121
return self.r.environ
2222

2323
def is_ajax(self):

iommi/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def group_actions(actions: Dict[str, Action]):
196196

197197
grouped_actions: List[Tuple[str, str, List[Action]]] = [
198198
(group_name, slugify(group_name), list(actions_in_group))
199-
for group_name, actions_in_group in groupby(actions_with_group, key=lambda l: l.group)
199+
for group_name, actions_in_group in groupby(actions_with_group, key=lambda x: x.group)
200200
]
201201

202202
for _, _, actions_in_group in grouped_actions:

iommi/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def rows(admin, request, included_filter=False, **_):
340340
app_name=app_name,
341341
model_name=app_name,
342342
name=model._meta.verbose_name_plural.capitalize(),
343-
url='%s/%s/' % (app_name, model_name),
343+
url='{}/{}/'.format(app_name, model_name),
344344
format=lambda row, **_: row.name,
345345
key=key,
346346
)

iommi/debug.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ class Meta:
133133
"""
134134
)
135135
sortable = False
136-
row__attrs__class__included = lambda row, **_: row.included
137136
page_size = None
138137

138+
@staticmethod
139+
def row__attrs__class__included(row, **_):
140+
return row.included
141+
139142
dunder_path = Column(
140143
cell__value=lambda row, **_: row.dunder_path,
141144
cell__format=dunder_path__format,
@@ -204,7 +207,7 @@ def local_debug_url_builder(filename, lineno):
204207
filename = join(settings.BASE_DIR, filename)
205208
if hasattr(settings, 'IOMMI_DEBUG_URL_MAPPING'):
206209
filename = filename.replace(*settings.IOMMI_DEBUG_URL_MAPPING)
207-
return "pycharm://open?file=%s" % (filename,) + ('' if lineno is None else "&line=%d" % (lineno,))
210+
return f"pycharm://open?file={filename}" + ('' if lineno is None else f"&line={lineno:d}")
208211

209212

210213
def src_debug_url_builder(filename, lineno=None):

iommi/debug__tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class NestedPage(Page):
4141
foo = 'foo'
4242

4343
class Meta:
44-
endpoints__fisk__func = lambda **_: None
44+
@staticmethod
45+
def endpoints__fisk__func(**_):
46+
return None
4547

4648
class MyPage(Page):
4749
bar = 'bar'

0 commit comments

Comments
 (0)