Skip to content

Commit f3b50de

Browse files
committed
Fix PEP8 max line length violation
close #434
1 parent d47fb2a commit f3b50de

File tree

113 files changed

+726
-963
lines changed

Some content is hidden

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

113 files changed

+726
-963
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ install:
1818
- pip install -r requirements-travis.txt
1919

2020
before_script:
21-
- flake8 ./exercises/ --max-line-length=99 --select=E,W
21+
- flake8 .
2222

2323
script:
2424
- ./test/check-exercises.py

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ python test/check-exercises.py
3535

3636
The Python code in this repo is meant to largely obey the [PEP8 style guide](https://www.python.org/dev/peps/pep-0008/).
3737

38-
This repo uses [flake8](http://flake8.readthedocs.org/en/latest/) to enforce the coding standard. When you submit a PR, it needs to pass the flake8 tool with no warnings, or it won't be accepted. Here are the settings used by the build system:
39-
40-
```
41-
flake8 [your-code-here.py] --max-line-length=99 --select=E,W
42-
```
38+
This repo uses [flake8](http://flake8.readthedocs.org/en/latest/) to enforce the coding standard. When you submit a PR, it needs to pass the flake8 tool with no warnings, or it won't be accepted.
4339

4440
## Pull Requests
4541

exercises/accumulate/accumulate_test.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def test_empty_sequence(self):
88
self.assertEqual([], accumulate([], lambda x: x / 2))
99

1010
def test_pow(self):
11-
self.assertEqual([1, 4, 9, 16, 25], accumulate([1, 2, 3, 4, 5],
12-
lambda x: x * x))
11+
self.assertEqual([1, 4, 9, 16, 25],
12+
accumulate([1, 2, 3, 4, 5], lambda x: x * x))
1313

1414
def test_divmod(self):
1515
inp = [10, 17, 23]
@@ -18,8 +18,10 @@ def test_divmod(self):
1818

1919
def test_composition(self):
2020
inp = [10, 17, 23]
21-
self.assertEqual(inp, accumulate(accumulate(inp, lambda x: divmod(x, 7)),
22-
lambda x: 7 * x[0] + x[1]))
21+
self.assertEqual(inp,
22+
accumulate(
23+
accumulate(inp, lambda x: divmod(x, 7)),
24+
lambda x: 7 * x[0] + x[1]))
2325

2426
def test_capitalize(self):
2527
inp = ['hello', 'world']
@@ -29,8 +31,10 @@ def test_capitalize(self):
2931
def test_recursive(self):
3032
inp = list('abc')
3133
out = [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']]
32-
self.assertEqual(out, accumulate(inp, lambda x: accumulate(list('123'),
33-
lambda y: x + y)))
34+
self.assertEqual(
35+
out,
36+
accumulate(inp,
37+
lambda x: accumulate(list('123'), lambda y: x + y)))
3438

3539

3640
if __name__ == '__main__':

exercises/acronym/acronym_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from acronym import abbreviate
44

5-
65
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
76

7+
88
class AcronymTest(unittest.TestCase):
99
def test_basic(self):
1010
self.assertEqual('PNG', abbreviate('Portable Network Graphics'))
@@ -25,7 +25,8 @@ def test_non_acronym_all_caps_word(self):
2525
self.assertEqual('GIMP', abbreviate('GNU Image Manipulation Program'))
2626

2727
def test_hyphenated(self):
28-
self.assertEqual('CMOS', abbreviate('Complementary metal-oxide semiconductor'))
28+
self.assertEqual('CMOS',
29+
abbreviate('Complementary metal-oxide semiconductor'))
2930

3031

3132
if __name__ == '__main__':

exercises/all-your-base/all_your_base_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
from all_your_base import rebase
44

5-
65
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
76

8-
class AllYourBaseTests(unittest.TestCase):
97

8+
class AllYourBaseTests(unittest.TestCase):
109
def test_single_bit_to_one_decimal(self):
1110
self.assertEqual(rebase(2, [1], 10), [1])
1211

exercises/all-your-base/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def from_digits(digits, base):
2-
return sum(n * base ** i for i, n in enumerate(reversed(digits)))
2+
return sum(n * base**i for i, n in enumerate(reversed(digits)))
33

44

55
def to_digits(number, base_to):

exercises/allergies/allergies_test.py

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

55

66
class AllergiesTests(unittest.TestCase):
7-
87
def test_no_allergies_means_not_allergic(self):
98
allergies = Allergies(0)
109
self.assertFalse(allergies.is_allergic_to('peanuts'))

exercises/allergies/example.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
class Allergies(object):
22

33
_allergies = [
4-
"eggs",
5-
"peanuts",
6-
"shellfish",
7-
"strawberries",
8-
"tomatoes",
9-
"chocolate",
10-
"pollen",
11-
"cats"
4+
"eggs", "peanuts", "shellfish", "strawberries", "tomatoes",
5+
"chocolate", "pollen", "cats"
126
]
137

148
def __init__(self, score):
@@ -19,5 +13,7 @@ def is_allergic_to(self, allergy):
1913

2014
@property
2115
def lst(self):
22-
return [allergy for allergy in self._allergies
23-
if self.is_allergic_to(allergy)]
16+
return [
17+
allergy for allergy in self._allergies
18+
if self.is_allergic_to(allergy)
19+
]

exercises/anagram/anagram_test.py

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,45 @@
66
class AnagramTests(unittest.TestCase):
77
def test_no_matches(self):
88
self.assertEqual(
9-
[],
10-
detect_anagrams('diaper', 'hello world zombies pants'.split())
11-
)
9+
[], detect_anagrams('diaper', 'hello world zombies pants'.split()))
1210

1311
def test_detect_simple_anagram(self):
14-
self.assertEqual(
15-
['tan'],
16-
detect_anagrams('ant', 'tan stand at'.split())
17-
)
12+
self.assertEqual(['tan'],
13+
detect_anagrams('ant', 'tan stand at'.split()))
1814

1915
def test_detect_multiple_anagrams(self):
2016
self.assertEqual(
2117
['stream', 'maters'],
22-
detect_anagrams('master', 'stream pigeon maters'.split())
23-
)
18+
detect_anagrams('master', 'stream pigeon maters'.split()))
2419

2520
def test_does_not_confuse_different_duplicates(self):
26-
self.assertEqual(
27-
[],
28-
detect_anagrams('galea', ['eagle'])
29-
)
21+
self.assertEqual([], detect_anagrams('galea', ['eagle']))
3022

3123
def test_eliminate_anagram_subsets(self):
32-
self.assertEqual(
33-
[],
34-
detect_anagrams('good', 'dog goody'.split())
35-
)
24+
self.assertEqual([], detect_anagrams('good', 'dog goody'.split()))
3625

3726
def test_detect_anagram(self):
3827
self.assertEqual(
3928
['inlets'],
40-
detect_anagrams('listen', 'enlists google inlets banana'.split())
41-
)
29+
detect_anagrams('listen', 'enlists google inlets banana'.split()))
4230

4331
def test_multiple_anagrams(self):
4432
self.assertEqual(
4533
'gallery regally largely'.split(),
4634
detect_anagrams(
4735
'allergy',
48-
'gallery ballerina regally clergy largely leading'.split()
49-
)
50-
)
36+
'gallery ballerina regally clergy largely leading'.split()))
5137

5238
def test_anagrams_are_case_insensitive(self):
5339
self.assertEqual(
5440
['Carthorse'],
5541
detect_anagrams('Orchestra',
56-
'cashregister Carthorse radishes'.split())
57-
)
42+
'cashregister Carthorse radishes'.split()))
5843

5944
def test_same_word_isnt_anagram(self):
60-
self.assertEqual(
61-
[],
62-
detect_anagrams('banana', ['banana'])
63-
)
45+
self.assertEqual([], detect_anagrams('banana', ['banana']))
6446

65-
self.assertEqual(
66-
[],
67-
detect_anagrams('go', 'go Go GO'.split())
68-
)
47+
self.assertEqual([], detect_anagrams('go', 'go Go GO'.split()))
6948

7049

7150
if __name__ == '__main__':

exercises/anagram/example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
def detect_anagrams(word, candidates):
2-
return [candidate
3-
for candidate in candidates
4-
if _letters(candidate) == _letters(word)
5-
if candidate.lower() != word.lower()]
2+
return [
3+
candidate for candidate in candidates
4+
if _letters(candidate) == _letters(word)
5+
if candidate.lower() != word.lower()
6+
]
67

78

89
def _letters(word):

0 commit comments

Comments
 (0)