Skip to content

Commit 683194c

Browse files
committed
Run black code formatter.
1 parent 5bea973 commit 683194c

10 files changed

+201
-182
lines changed

.prepare-commit-msg.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,20 @@
3030
# e.g. for a branch named 'issue-123', the commit message will start with
3131
# '[#123]'
3232
# If you wish to use a diferent prefix on branch names, change it here.
33-
issue_prefix = 'issue-'
33+
issue_prefix = "issue-"
3434

3535
commit_msg_filepath = sys.argv[1]
36-
branch = check_output(
37-
['git', 'symbolic-ref', '--short', 'HEAD']
38-
).strip().decode(encoding='UTF-8')
36+
branch = (
37+
check_output(["git", "symbolic-ref", "--short", "HEAD"])
38+
.strip()
39+
.decode(encoding="UTF-8")
40+
)
3941

4042
if branch.startswith(issue_prefix):
41-
issue_number = re.match('%s(.*)' % issue_prefix, branch).group(1)
43+
issue_number = re.match("%s(.*)" % issue_prefix, branch).group(1)
4244
print("prepare-commit-msg: Prepending [#%s] to commit message" % issue_number)
4345

44-
with open(commit_msg_filepath, 'r+') as f:
46+
with open(commit_msg_filepath, "r+") as f:
4547
content = f.read()
4648
f.seek(0, 0)
4749
f.write("[#%s] %s" % (issue_number, content))

axelrod/graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def cycle(length, directed=False):
115115
-------
116116
a Graph object for the cycle
117117
"""
118-
edges = [(i, i+1) for i in range(length-1)]
118+
edges = [(i, i + 1) for i in range(length - 1)]
119119
edges.append((length - 1, 0))
120120
return Graph(edges=edges, directed=directed)
121121

@@ -136,7 +136,7 @@ def complete_graph(size, loops=True):
136136
-------
137137
a Graph object for the complete graph
138138
"""
139-
edges = [(i, j) for i in range(size) for j in range(i+1, size)]
139+
edges = [(i, j) for i in range(size) for j in range(i + 1, size)]
140140
graph = Graph(edges=edges, directed=False)
141141

142142
if loops:

axelrod/moran.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ def __init__(
156156
self.fitness_transformation = fitness_transformation
157157
# Map players to graph vertices
158158
self.locations = sorted(interaction_graph.vertices)
159-
self.index = dict(
160-
zip(sorted(interaction_graph.vertices), range(len(players)))
161-
)
159+
self.index = dict(zip(sorted(interaction_graph.vertices), range(len(players))))
162160

163161
def set_players(self) -> None:
164162
"""Copy the initial players into the first population."""

axelrod/strategies/human.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def validate(self, document) -> None:
2222
text = document.text
2323

2424
if text and text.upper() not in ["C", "D"]:
25-
raise ValidationError(message="Action must be C or D",
26-
cursor_position=0)
25+
raise ValidationError(message="Action must be C or D", cursor_position=0)
2726

2827

2928
class Human(Player):

axelrod/tests/unit/test_graph.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class TestGraph(unittest.TestCase):
8-
98
def assert_out_mapping(self, g, expected_out_mapping):
109
self.assertDictEqual(g.out_mapping, expected_out_mapping)
1110
for node, out_dict in expected_out_mapping.items():
@@ -97,7 +96,6 @@ def test_add_loops_with_existing_loop_and_using_strings(self):
9796

9897

9998
class TestCycle(unittest.TestCase):
100-
10199
def test_length_1_directed(self):
102100
g = graph.cycle(1, directed=True)
103101
self.assertEqual(g.vertices, [0])
@@ -124,7 +122,7 @@ def test_length_3_directed(self):
124122
g = graph.cycle(3, directed=True)
125123
self.assertEqual(g.vertices, [0, 1, 2])
126124
self.assertEqual(g.edges, [(0, 1), (1, 2), (2, 0)])
127-
125+
128126
def test_length_3_undirected(self):
129127
g = graph.cycle(3, directed=False)
130128
edges = [(0, 1), (1, 0), (1, 2), (2, 1), (2, 0), (0, 2)]
@@ -156,7 +154,6 @@ def test_length_4_undirected(self):
156154

157155

158156
class TestComplete(unittest.TestCase):
159-
160157
def test_size_2(self):
161158
g = graph.complete_graph(2, loops=False)
162159
self.assertEqual(g.vertices, [0, 1])
@@ -209,7 +206,7 @@ def test_size_2_with_loops(self):
209206
self.assertEqual(g.vertices, [0, 1])
210207
self.assertEqual(g.edges, [(0, 1), (1, 0), (0, 0), (1, 1)])
211208
self.assertEqual(g.directed, False)
212-
209+
213210
def test_size_3_with_loops(self):
214211
g = graph.complete_graph(3, loops=True)
215212
self.assertEqual(g.vertices, [0, 1, 2])

0 commit comments

Comments
 (0)