Skip to content

Commit 38f1542

Browse files
committed
Fix PEP8 issues (BLACK IT!). Configure flake8
1 parent 88a9e58 commit 38f1542

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+180
-269
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ script:
2626
- PYTHONPATH=. nosetests -s -v --with-doctest --with-cov --cover-package . --logging-level=INFO -v .
2727
# Actually run all the scripts, contributing to coverage
2828
- PYTHONPATH=. ./run_all.sh
29-
# for now failure in flaking is ignored
30-
- flake8 *py || echo "PEP8 the code"
29+
- flake8 *py
3130

3231
after_success:
3332
- coveralls

behavioral/catalog.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def __init__(self, param):
2020
# dictionary that will be used to determine which static method is
2121
# to be executed but that will be also used to store possible param
2222
# value
23-
self._static_method_choices = {'param_value_1': self._static_method_1,
24-
'param_value_2': self._static_method_2}
23+
self._static_method_choices = {'param_value_1': self._static_method_1, 'param_value_2': self._static_method_2}
2524

2625
# simple test to validate param value
2726
if param in self._static_method_choices.keys():
@@ -68,8 +67,7 @@ def _instance_method_1(self):
6867
def _instance_method_2(self):
6968
print("Value {}".format(self.x2))
7069

71-
_instance_method_choices = {'param_value_1': _instance_method_1,
72-
'param_value_2': _instance_method_2}
70+
_instance_method_choices = {'param_value_1': _instance_method_1, 'param_value_2': _instance_method_2}
7371

7472
def main_method(self):
7573
"""will execute either _instance_method_1 or _instance_method_2
@@ -104,8 +102,7 @@ def _class_method_1(cls):
104102
def _class_method_2(cls):
105103
print("Value {}".format(cls.x2))
106104

107-
_class_method_choices = {'param_value_1': _class_method_1,
108-
'param_value_2': _class_method_2}
105+
_class_method_choices = {'param_value_1': _class_method_1, 'param_value_2': _class_method_2}
109106

110107
def main_method(self):
111108
"""will execute either _class_method_1 or _class_method_2
@@ -137,8 +134,7 @@ def _static_method_1():
137134
def _static_method_2():
138135
print("executed method 2!")
139136

140-
_static_method_choices = {'param_value_1': _static_method_1,
141-
'param_value_2': _static_method_2}
137+
_static_method_choices = {'param_value_1': _static_method_1, 'param_value_2': _static_method_2}
142138

143139
def main_method(self):
144140
"""will execute either _static_method_1 or _static_method_2
@@ -168,6 +164,7 @@ def main():
168164
test = CatalogStatic('param_value_1')
169165
test.main_method()
170166

167+
171168
if __name__ == "__main__":
172169

173170
main()

behavioral/chain.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,35 @@ def _handle(self, request):
4444

4545

4646
class ConcreteHandler1(Handler):
47-
4847
def _handle(self, request):
4948
if 0 < request <= 10:
5049
print('request {} handled in handler 1'.format(request))
5150
return True
5251

5352

5453
class ConcreteHandler2(Handler):
55-
5654
def _handle(self, request):
5755
if 10 < request <= 20:
5856
print('request {} handled in handler 2'.format(request))
5957
return True
6058

6159

6260
class ConcreteHandler3(Handler):
63-
6461
def _handle(self, request):
6562
if 20 < request <= 30:
6663
print('request {} handled in handler 3'.format(request))
6764
return True
6865

6966

7067
class DefaultHandler(Handler):
71-
7268
def _handle(self, request):
7369
print('end of chain, no handler for {}'.format(request))
7470
return True
7571

7672

7773
class Client(object):
78-
7974
def __init__(self):
80-
self.handler = ConcreteHandler1(
81-
ConcreteHandler3(ConcreteHandler2(DefaultHandler())))
75+
self.handler = ConcreteHandler1(ConcreteHandler3(ConcreteHandler2(DefaultHandler())))
8276

8377
def delegate(self, requests):
8478
for request in requests:
@@ -90,6 +84,7 @@ def start(*args, **kwargs):
9084
cr = func(*args, **kwargs)
9185
next(cr)
9286
return cr
87+
9388
return start
9489

9590

@@ -131,7 +126,6 @@ def default_coroutine():
131126

132127

133128
class ClientCoroutine:
134-
135129
def __init__(self):
136130
self.target = coroutine1(coroutine3(coroutine2(default_coroutine())))
137131

@@ -141,12 +135,12 @@ def delegate(self, requests):
141135

142136

143137
def timeit(func):
144-
145138
def count(*args, **kwargs):
146139
start = time.time()
147140
res = func(*args, **kwargs)
148141
count._time = time.time() - start
149142
return res
143+
150144
return count
151145

152146

behavioral/chaining_method.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class Person(object):
8-
98
def __init__(self, name, action):
109
self.name = name
1110
self.action = action
@@ -16,7 +15,6 @@ def do_action(self):
1615

1716

1817
class Action(object):
19-
2018
def __init__(self, name):
2119
self.name = name
2220

@@ -27,6 +25,7 @@ def amount(self, val):
2725
def stop(self):
2826
print('then stop')
2927

28+
3029
if __name__ == '__main__':
3130

3231
move = Action('move')

behavioral/command.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class MoveFileCommand(object):
15-
1615
def __init__(self, src, dest):
1716
self.src = src
1817
self.dest = dest
@@ -36,9 +35,9 @@ def main():
3635
command_stack.append(MoveFileCommand('bar.txt', 'baz.txt'))
3736

3837
# verify that none of the target files exist
39-
assert(not lexists("foo.txt"))
40-
assert(not lexists("bar.txt"))
41-
assert(not lexists("baz.txt"))
38+
assert not lexists("foo.txt")
39+
assert not lexists("bar.txt")
40+
assert not lexists("baz.txt")
4241
try:
4342
with open("foo.txt", "w"): # Creating the file
4443
pass
@@ -53,6 +52,7 @@ def main():
5352
finally:
5453
os.unlink("foo.txt")
5554

55+
5656
if __name__ == "__main__":
5757
main()
5858

behavioral/iterator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def count_to(count):
1818
for number in numbers[:count]:
1919
yield number
2020

21+
2122
# Test the generator
2223
count_to_two = lambda: count_to(2)
2324
count_to_five = lambda: count_to(5)

behavioral/mediator.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class TC:
16-
1716
def __init__(self):
1817
self._tm = None
1918
self._bProblem = 0
@@ -46,7 +45,6 @@ def setProblem(self, value):
4645

4746

4847
class Reporter:
49-
5048
def __init__(self):
5149
self._tm = None
5250

@@ -63,7 +61,6 @@ def setTM(self, tm):
6361

6462

6563
class DB:
66-
6764
def __init__(self):
6865
self._tm = None
6966

@@ -83,7 +80,6 @@ def setTM(self, tm):
8380

8481

8582
class TestManager:
86-
8783
def __init__(self):
8884
self._reporter = None
8985
self._db = None

behavioral/memento.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Transaction(object):
2727
2828
This is, in fact, just syntactic sugar around a memento closure.
2929
"""
30+
3031
deep = False
3132
states = []
3233

@@ -65,7 +66,6 @@ def transaction(*args, **kwargs):
6566

6667

6768
class NumObj(object):
68-
6969
def __init__(self, value):
7070
self.value = value
7171

behavioral/observer.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class Subject(object):
15-
1615
def __init__(self):
1716
self._observers = []
1817

@@ -34,7 +33,6 @@ def notify(self, modifier=None):
3433

3534
# Example usage
3635
class Data(Subject):
37-
3836
def __init__(self, name=''):
3937
Subject.__init__(self)
4038
self.name = name
@@ -51,17 +49,13 @@ def data(self, value):
5149

5250

5351
class HexViewer:
54-
5552
def update(self, subject):
56-
print(u'HexViewer: Subject %s has data 0x%x' %
57-
(subject.name, subject.data))
53+
print(u'HexViewer: Subject %s has data 0x%x' % (subject.name, subject.data))
5854

5955

6056
class DecimalViewer:
61-
6257
def update(self, subject):
63-
print(u'DecimalViewer: Subject %s has data %d' %
64-
(subject.name, subject.data))
58+
print(u'DecimalViewer: Subject %s has data %d' % (subject.name, subject.data))
6559

6660

6761
# Example usage...

behavioral/publish_subscribe.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
class Provider:
11-
1211
def __init__(self):
1312
self.msg_queue = []
1413
self.subscribers = {}
@@ -30,7 +29,6 @@ def update(self):
3029

3130

3231
class Publisher:
33-
3432
def __init__(self, msg_center):
3533
self.provider = msg_center
3634

@@ -39,7 +37,6 @@ def publish(self, msg):
3937

4038

4139
class Subscriber:
42-
4340
def __init__(self, name, msg_center):
4441
self.name = name
4542
self.provider = msg_center

0 commit comments

Comments
 (0)