Skip to content

Commit b2939c1

Browse files
committed
Fixes for latest version of pep8
1 parent 0669f50 commit b2939c1

File tree

7 files changed

+31
-9
lines changed

7 files changed

+31
-9
lines changed

env/pip-selfcheck.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"last_check":"2015-02-09T17:34:33Z","pypi_version":"6.0.8"}

rest_framework/templatetags/rest_framework.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru
154154
155155
If autoescape is True, the link text and URLs will get autoescaped.
156156
"""
157-
trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
157+
def trim_url(x, limit=trim_url_limit):
158+
return limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
159+
158160
safe_input = isinstance(text, SafeData)
159161
words = word_split_re.split(force_text(text))
160162
for i, word in enumerate(words):

tests/test_authentication.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ def test_post_json_passing_token_auth(self):
205205
def test_post_json_makes_one_db_query(self):
206206
"""Ensure that authenticating a user using a token performs only one DB query"""
207207
auth = "Token " + self.key
208-
func_to_test = lambda: self.csrf_client.post('/token/', {'example': 'example'}, format='json', HTTP_AUTHORIZATION=auth)
208+
209+
def func_to_test():
210+
return self.csrf_client.post('/token/', {'example': 'example'}, format='json', HTTP_AUTHORIZATION=auth)
211+
209212
self.assertNumQueries(1, func_to_test)
210213

211214
def test_post_form_failing_token_auth(self):

tests/test_relations_hyperlink.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
request = factory.get('/') # Just to ensure we have a request in the serializer context
1313

1414

15-
dummy_view = lambda request, pk: None
15+
def dummy_view(request, pk):
16+
pass
17+
1618

1719
urlpatterns = patterns(
1820
'',

tests/test_renderers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828
DUMMYSTATUS = status.HTTP_200_OK
2929
DUMMYCONTENT = 'dummycontent'
3030

31-
RENDERER_A_SERIALIZER = lambda x: ('Renderer A: %s' % x).encode('ascii')
32-
RENDERER_B_SERIALIZER = lambda x: ('Renderer B: %s' % x).encode('ascii')
31+
32+
def RENDERER_A_SERIALIZER(x):
33+
return ('Renderer A: %s' % x).encode('ascii')
34+
35+
36+
def RENDERER_B_SERIALIZER(x):
37+
return ('Renderer B: %s' % x).encode('ascii')
3338

3439

3540
expected_results = [

tests/test_response.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ class MockTextMediaRenderer(BaseRenderer):
3838
DUMMYSTATUS = status.HTTP_200_OK
3939
DUMMYCONTENT = 'dummycontent'
4040

41-
RENDERER_A_SERIALIZER = lambda x: ('Renderer A: %s' % x).encode('ascii')
42-
RENDERER_B_SERIALIZER = lambda x: ('Renderer B: %s' % x).encode('ascii')
41+
42+
def RENDERER_A_SERIALIZER(x):
43+
return ('Renderer A: %s' % x).encode('ascii')
44+
45+
46+
def RENDERER_B_SERIALIZER(x):
47+
return ('Renderer B: %s' % x).encode('ascii')
4348

4449

4550
class RendererA(BaseRenderer):

tests/test_throttling.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def setUp(self):
188188
class XYScopedRateThrottle(ScopedRateThrottle):
189189
TIMER_SECONDS = 0
190190
THROTTLE_RATES = {'x': '3/min', 'y': '1/min'}
191-
timer = lambda self: self.TIMER_SECONDS
191+
192+
def timer(self):
193+
return self.TIMER_SECONDS
192194

193195
class XView(APIView):
194196
throttle_classes = (XYScopedRateThrottle,)
@@ -290,7 +292,9 @@ def setUp(self):
290292
class Throttle(ScopedRateThrottle):
291293
THROTTLE_RATES = {'test_limit': '1/day'}
292294
TIMER_SECONDS = 0
293-
timer = lambda self: self.TIMER_SECONDS
295+
296+
def timer(self):
297+
return self.TIMER_SECONDS
294298

295299
class View(APIView):
296300
throttle_classes = (Throttle,)

0 commit comments

Comments
 (0)