Skip to content

Commit 670f952

Browse files
cclausspoyea
andauthored
Travis CI: Don’t allow bare exceptions (TheAlgorithms#1734)
* Travis CI: Don’t allow bare exceptions * fixup! Format Python code with psf/black push * except IOError: * except IOError: * Update hamming_code.py * IndexError * Get rid of the nonsense logic Co-authored-by: John Law <johnlaw.po@gmail.com>
1 parent f52b97f commit 670f952

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ before_install: pip install --upgrade pip setuptools
55
install: pip install -r requirements.txt
66
before_script:
77
- black --check . || true
8-
- flake8 . --count --select=E101,E9,F4,F63,F7,F82,W191 --show-source --statistics
8+
- flake8 . --count --select=E101,E722,E9,F4,F63,F7,F82,W191 --show-source --statistics
99
- flake8 . --count --exit-zero --max-line-length=127 --statistics
1010
script:
1111
- scripts/validate_filenames.py # no uppercase, no spaces, in a directory

ciphers/transposition_cipher.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import math
22

3-
'''
3+
"""
44
In cryptography, the TRANSPOSITION cipher is a method of encryption where the
55
positions of plaintext are shifted a certain number(determined by the key) that
66
follows a regular system that results in the permuted text, known as the encrypted
77
text. The type of transposition cipher demonstrated under is the ROUTE cipher.
8-
'''
8+
"""
9+
10+
911
def main():
1012
message = input("Enter message: ")
1113
key = int(input("Enter key [2-%s]: " % (len(message) - 1)))

ciphers/xor_cipher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def encrypt_file(self, file, key=0):
148148
for line in fin:
149149
fout.write(self.encrypt_string(line, key))
150150

151-
except:
151+
except IOError:
152152
return False
153153

154154
return True
@@ -173,7 +173,7 @@ def decrypt_file(self, file, key):
173173
for line in fin:
174174
fout.write(self.decrypt_string(line, key))
175175

176-
except:
176+
except IOError:
177177
return False
178178

179179
return True

hashes/hamming_code.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def emitterConverter(sizePar, data):
125125
if x != None:
126126
try:
127127
aux = (binPos[contLoop])[-1 * (bp)]
128-
except:
128+
except IndexError:
129129
aux = "0"
130130
if aux == "1":
131131
if x == "1":
@@ -229,7 +229,7 @@ def receptorConverter(sizePar, data):
229229
if x != None:
230230
try:
231231
aux = (binPos[contLoop])[-1 * (bp)]
232-
except:
232+
except IndexError:
233233
aux = "0"
234234
if aux == "1":
235235
if x == "1":

linear_algebra/src/test_linear_algebra.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ def test_component(self):
1919
x = Vector([1, 2, 3])
2020
self.assertEqual(x.component(0), 1)
2121
self.assertEqual(x.component(2), 3)
22-
try:
23-
y = Vector()
24-
self.assertTrue(False)
25-
except:
26-
self.assertTrue(True)
22+
y = Vector()
2723

2824
def test_str(self):
2925
"""

0 commit comments

Comments
 (0)