Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 1cb36a2

Browse files
committed
Code formatting (black)
1 parent c38c05f commit 1cb36a2

26 files changed

+29
-78
lines changed

abstract_factory.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,12 @@ def area(self):
145145

146146

147147
class _TriangleEquilateral(_Triangle):
148-
149148
@property
150149
def perimeter(self):
151150
return "3a"
152151

153152

154153
class _TriangleIsosceles(_Triangle):
155-
156154
@property
157155
def perimeter(self):
158156
return "2a+b"
@@ -179,7 +177,6 @@ def area(self):
179177

180178

181179
class _Square(_Quadrilateral):
182-
183180
@property
184181
def perimeter(self):
185182
return "4a"
@@ -190,7 +187,6 @@ def area(self):
190187

191188

192189
class _Rectangle(_Quadrilateral):
193-
194190
@property
195191
def perimeter(self):
196192
return "2a+2b"

adapter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ class USSocket(Socket):
4747

4848
class EUAdapter(object):
4949
"""EUAdapter encapsulates client (Smartphone) and supplier (EUSocket)."""
50+
5051
input_voltage = EUSocket.output_voltage
5152
output_voltage = Smartphone.max_input_voltage
5253

5354

5455
class USAdapter(object):
5556
"""USAdapter encapsulates client (Smartphone) and supplier (USSocket)."""
57+
5658
input_voltage = USSocket.output_voltage
5759
output_voltage = Smartphone.max_input_voltage
5860

@@ -67,19 +69,19 @@ class CannotTransformVoltage(Exception):
6769
6870
This exception represents the fact that an adapter could not provide the
6971
right voltage to the Smartphone if the voltage of the Socket is wrong."""
72+
7073
pass
7174

7275

7376
class SmartphoneAdapter(Smartphone, Socket):
74-
7577
@classmethod
7678
def transform_voltage(cls, input_voltage):
7779
if input_voltage == cls.output_voltage:
7880
return cls.max_input_voltage
7981

8082
else:
8183
raise CannotTransformVoltage(
82-
"Can\'t transform {0}-{1}V. This adapter transforms {2}-{1}V.".format(
84+
"Can't transform {0}-{1}V. This adapter transforms {2}-{1}V.".format(
8385
input_voltage, cls.max_input_voltage, cls.output_voltage
8486
)
8587
)
@@ -99,11 +101,13 @@ class SmartphoneEUAdapter(SmartphoneAdapter, EUSocket):
99101
Note: SmartphoneAdapter already inherited from Smartphone and Socket, but by
100102
re-inheriting from EUSocket we redefine all the stuff inherited from Socket.
101103
"""
104+
102105
pass
103106

104107

105108
class SmartphoneUSAdapter(SmartphoneAdapter, USSocket):
106109
"""System (smartphone + adapter) for an American Socket."""
110+
107111
pass
108112

109113

borg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ChildNotShare(Borg):
4040
instances of Borg or any of Borg's subclass. That's because we override
4141
_shared_state = {}.
4242
"""
43+
4344
_shared_state = {}
4445

4546
def __init__(self, name=None, age=None):

bridge.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
class Website(ABC):
21-
2221
def __init__(self, implementation):
2322
# encapsulate an instance of a concrete implementation class
2423
self._implementation = implementation
@@ -37,7 +36,6 @@ def show_page(self):
3736

3837

3938
class FreeWebsite(Website):
40-
4139
def show_page(self):
4240
ads = self._implementation.get_ads()
4341
text = self._implementation.get_excerpt()
@@ -52,7 +50,6 @@ def show_page(self):
5250

5351

5452
class PaidWebsite(Website):
55-
5653
def show_page(self):
5754
text = self._implementation.get_article()
5855
print(text)
@@ -63,7 +60,6 @@ def show_page(self):
6360

6461

6562
class Implementation(ABC):
66-
6763
def get_excerpt(self):
6864
return "excerpt from the article"
6965

@@ -82,7 +78,6 @@ def get_call_to_action(self):
8278

8379

8480
class ImplementationA(Implementation):
85-
8681
def get_call_to_action(self):
8782
return "Pay 10 $ a month to remove ads"
8883

@@ -91,7 +86,6 @@ def get_call_to_action(self):
9186

9287

9388
class ImplementationB(Implementation):
94-
9589
def get_call_to_action(self):
9690
return "Remove ads with just 10 $ a month"
9791

builder.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __str__(self):
2424

2525
class ConeIceCream(IceCream):
2626
"""Concrete Product 1."""
27+
2728
pass
2829

2930

@@ -113,9 +114,9 @@ def build_product(self, flavors):
113114
-------
114115
ConeIceCream or CupIceCream
115116
"""
116-
return self.builder.set_flavors(
117-
flavors
118-
).set_toppings().add_spoon().get_product()
117+
return (
118+
self.builder.set_flavors(flavors).set_toppings().add_spoon().get_product()
119+
)
119120

120121

121122
# Client: it creates a Director object and configures it with a Builder object.

chain_of_responsability.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class CannotHandleRequest(Exception):
99

1010

1111
class Node(ABC):
12-
1312
def __init__(self):
1413
self._next_node = None
1514

@@ -55,7 +54,6 @@ def handle(self, request, *args, **kwargs):
5554

5655

5756
class WatcherNode(Node):
58-
5957
def watch(self, request, *args, **kwargs):
6058
# implement actual behavior here
6159
string = "Process request {}".format(request)
@@ -67,7 +65,6 @@ def watch(self, request, *args, **kwargs):
6765

6866

6967
class BuyerNode(Node):
70-
7168
def buy(self, request, *args, **kwargs):
7269
# implement actual behavior here
7370
string = "Process request {}".format(request)
@@ -79,7 +76,6 @@ def buy(self, request, *args, **kwargs):
7976

8077

8178
class EaterNode(Node):
82-
8379
def eat(self, request, *args, **kwargs):
8480
# implement actual behavior here
8581
string = "Process request {}".format(request)

closure.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66

77
def outer(x):
8-
98
def inner(y):
109
return x + y
1110

1211
return inner
1312

1413

1514
def outer2(x):
16-
1715
def inner2(y, x=x):
1816
return x + y
1917

command.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def move_command(x, source, dest, *args, **kwargs):
2525

2626

2727
class Queue(object):
28-
2928
def __init__(self):
3029
self._commands = list()
3130
self._history = list()

composite.py

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

55

66
class Component(ABC):
7-
87
def __init__(self, name):
98
self.name = name
109
self.level = 0
@@ -20,13 +19,11 @@ def traverse(self):
2019

2120

2221
class Leaf(Component):
23-
2422
def traverse(self):
2523
print("{}{}".format(self.indentation, self.name))
2624

2725

2826
class Composite(Component):
29-
3027
def __init__(self, name):
3128
# super().__init__(name) # ok in Python 3.x, not in 2.x
3229
super(self.__class__, self).__init__(name) # also ok in Python 2.x

decorator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def another_method(self):
2323

2424

2525
class ComponentDecorator(object):
26-
2726
def __init__(self, decoratee):
2827
self._decoratee = decoratee # reference of the original object
2928

0 commit comments

Comments
 (0)