Skip to content

Commit 21d38dd

Browse files
committed
Flake8 fixes
1 parent c2b6bb1 commit 21d38dd

File tree

10 files changed

+58
-34
lines changed

10 files changed

+58
-34
lines changed

pyamf/__init__.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -853,15 +853,22 @@ def register_package(module=None, package=None, separator='.', ignore=None,
853853
module = prev_frame.f_locals
854854

855855
if type(module) is dict:
856-
has = lambda x: x in module
856+
def has(x):
857+
return x in module
858+
857859
get = module.__getitem__
858860
elif type(module) is list:
859-
has = lambda x: x in module
861+
def has(x):
862+
return x in module
863+
860864
get = module.__getitem__
861865
strict = False
862866
else:
863-
has = lambda x: hasattr(module, x)
864-
get = lambda x: getattr(module, x)
867+
def has(x):
868+
return hasattr(module, x)
869+
870+
def get(x):
871+
return getattr(module, x)
865872

866873
if package is None:
867874
if has('__name__'):

pyamf/remoting/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
#: List of available status response codes.
4343
STATUS_CODES = {
44-
STATUS_OK: '/onResult',
44+
STATUS_OK: '/onResult',
4545
STATUS_ERROR: '/onStatus',
4646
STATUS_DEBUG: '/onDebugEvents'
4747
}

pyamf/remoting/gateway/django.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
@since: 0.1.0
1212
"""
1313

14+
import pyamf
15+
from pyamf import remoting
16+
from pyamf.remoting import gateway
17+
18+
1419
django = __import__('django.http')
1520
http = django.http
1621
conf = __import__('django.conf')
1722
conf = conf.conf
1823

19-
import pyamf
20-
from pyamf import remoting
21-
from pyamf.remoting import gateway
22-
2324
__all__ = ['DjangoGateway']
2425

2526

pyamf/remoting/gateway/google.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import sys
1616
import os.path
1717

18+
from pyamf import remoting, DecodeError
19+
from pyamf.remoting import gateway
20+
1821
try:
1922
sys.path.remove(os.path.dirname(os.path.abspath(__file__)))
2023
except ValueError:
@@ -23,9 +26,6 @@
2326
google = __import__('google.appengine.ext.webapp')
2427
webapp = google.appengine.ext.webapp
2528

26-
from pyamf import remoting, DecodeError
27-
from pyamf.remoting import gateway
28-
2929
__all__ = ['WebAppGateway']
3030

3131

pyamf/remoting/gateway/twisted.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import sys
1515
import os.path
1616

17+
from pyamf import remoting
18+
from pyamf.remoting import gateway, amf0, amf3
19+
1720
try:
1821
sys.path.remove('')
1922
except ValueError:
@@ -35,9 +38,6 @@
3538
resource = twisted.web.resource
3639
server = twisted.web.server
3740

38-
from pyamf import remoting
39-
from pyamf.remoting import gateway, amf0, amf3
40-
4141
__all__ = ['TwistedGateway']
4242

4343

@@ -324,8 +324,10 @@ def eb(failure):
324324
self.logger.error(errMesg)
325325
self.logger.error(failure.getTraceback())
326326

327-
body = "500 Internal Server Error\n\nThere was an error encoding " \
327+
body = (
328+
"500 Internal Server Error\n\nThere was an error encoding "
328329
"the response."
330+
)
329331

330332
if self.debug:
331333
body += "\n\nTraceback:\n\n%s" % failure.getTraceback()

pyamf/tests/test_amf0.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ def test_elementtree_tag(self):
360360
encoding an xml type.
361361
"""
362362
class NotAnElement(object):
363-
items = lambda self: []
363+
def items(self):
364+
return []
364365

365366
def __iter__(self):
366367
return iter([])

pyamf/tests/test_amf3.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ class Person(object):
429429

430430
def test_elementtree_tag(self):
431431
class NotAnElement(object):
432-
items = lambda self: []
432+
def items(self):
433+
return []
433434

434435
def __iter__(self):
435436
return iter([])
@@ -473,20 +474,20 @@ def test_29b_ints(self):
473474

474475
def test_number(self):
475476
vals = [
476-
(0, '\x04\x00'),
477-
(0.2, '\x05\x3f\xc9\x99\x99\x99\x99\x99\x9a'),
478-
(1, '\x04\x01'),
479-
(127, '\x04\x7f'),
480-
(128, '\x04\x81\x00'),
481-
(0x3fff, '\x04\xff\x7f'),
482-
(0x4000, '\x04\x81\x80\x00'),
477+
(0, '\x04\x00'),
478+
(0.2, '\x05\x3f\xc9\x99\x99\x99\x99\x99\x9a'),
479+
(1, '\x04\x01'),
480+
(127, '\x04\x7f'),
481+
(128, '\x04\x81\x00'),
482+
(0x3fff, '\x04\xff\x7f'),
483+
(0x4000, '\x04\x81\x80\x00'),
483484
(0x1FFFFF, '\x04\xff\xff\x7f'),
484485
(0x200000, '\x04\x80\xc0\x80\x00'),
485486
(0x3FFFFF, '\x04\x80\xff\xff\xff'),
486487
(0x400000, '\x04\x81\x80\x80\x00'),
487-
(-1, '\x04\xff\xff\xff\xff'),
488-
(42, '\x04\x2a'),
489-
(-123, '\x04\xff\xff\xff\x85'),
488+
(-1, '\x04\xff\xff\xff\xff'),
489+
(42, '\x04\x2a'),
490+
(-123, '\x04\xff\xff\xff\x85'),
490491
(amf3.MIN_29B_INT, '\x04\xc0\x80\x80\x00'),
491492
(amf3.MAX_29B_INT, '\x04\xbf\xff\xff\xff'),
492493
(1.23456789, '\x05\x3f\xf3\xc0\xca\x42\x83\xde\x1b')

pyamf/tests/test_gateway.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ def test_empty_target(self):
472472
class QueryBrowserTestCase(unittest.TestCase):
473473
def test_request(self):
474474
gw = gateway.BaseGateway()
475-
echo = lambda x: x
475+
476+
def echo(x):
477+
return x
476478

477479
gw.addService(echo, 'echo', description='This is a test')
478480

@@ -507,7 +509,9 @@ def _auth(self, username, password):
507509

508510
def test_gateway(self):
509511
gw = gateway.BaseGateway(authenticator=self._auth)
510-
echo = lambda x: x
512+
513+
def echo(x):
514+
return x
511515

512516
gw.addService(echo, 'echo')
513517

@@ -524,7 +528,9 @@ def test_gateway(self):
524528

525529
def test_service(self):
526530
gw = gateway.BaseGateway()
527-
echo = lambda x: x
531+
532+
def echo(x):
533+
return x
528534

529535
gw.addService(echo, 'echo', authenticator=self._auth)
530536

pyamf/util/__init__.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,16 @@ def get_class_meta(klass):
172172
a = klass.__amf__
173173

174174
if type(a) is dict:
175-
in_func = lambda x: x in a
175+
def in_func(x):
176+
return x in a
177+
176178
get_func = a.__getitem__
177179
else:
178-
in_func = lambda x: hasattr(a, x)
179-
get_func = lambda x: getattr(a, x)
180+
def in_func(x):
181+
return hasattr(a, x)
182+
183+
def get_func(x):
184+
return getattr(a, x)
180185

181186
for prop in ['alias', 'amf3', 'dynamic', 'external']:
182187
if in_func(prop):

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ sourcecode: yes
5252

5353
[flake8]
5454
exclude=doc,.ropeproject
55+
ignore=E402

0 commit comments

Comments
 (0)