Skip to content

Commit 083da7b

Browse files
committed
flake is invalidating some file I did not touch to implement header support
I put TODO in these and marked invalid statements for noqa, as they are generally ok
1 parent 86ae339 commit 083da7b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

sparkpost/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ class SparkPostException(Exception):
55
class SparkPostAPIException(SparkPostException):
66
"Handle 4xx and 5xx errors from the SparkPost API"
77
def __init__(self, response, *args, **kwargs):
8+
# noinspection PyBroadException
89
try:
910
errors = response.json()['errors']
1011
error_template = "{message} Code: {code} Description: {desc} \n"
1112
errors = [error_template.format(message=e.get('message', ''),
1213
code=e.get('code', 'none'),
1314
desc=e.get('description', 'none'))
1415
for e in errors]
15-
except:
16+
# TODO: select exception to catch here
17+
except: # noqa: E722
1618
errors = [response.text or ""]
1719
self.status = response.status_code
1820
self.response = response

sparkpost/tornado/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ def request(self, method, uri, headers, **kwargs):
2020
raise gen.Return(True)
2121
if response.code == 200:
2222
result = None
23+
# noinspection PyBroadException
2324
try:
2425
result = json.loads(response.body.decode("utf-8"))
25-
except:
26+
# TODO: select exception to catch here
27+
except: # noqa: E722
2628
pass
2729
if result:
2830
if 'results' in result:

sparkpost/tornado/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
class SparkPostAPIException(RequestsSparkPostAPIException):
77
def __init__(self, response, *args, **kwargs):
88
errors = None
9+
# noinspection PyBroadException
910
try:
1011
data = json.loads(response.body.decode("utf-8"))
1112
if data:
1213
errors = data['errors']
1314
errors = [e['message'] + ': ' + e.get('description', '')
1415
for e in errors]
15-
except:
16+
# TODO: select exception to catch here
17+
except: # noqa: E722
1618
pass
1719
if not errors:
1820
errors = [response.body.decode("utf-8") or ""]

test/test_templates.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
try:
22
from urllib.parse import urlparse
3-
except:
3+
# TODO: select exception to catch here
4+
except: # noqa: E722
45
from urlparse import urlparse
56

67
import pytest

0 commit comments

Comments
 (0)