Skip to content

Commit beed6e4

Browse files
author
SendGrid's DX Team
authored
Merge pull request #250 from andriisoldatenko/fix-pep8-errors
Improve code quality
2 parents 9086caf + ecc37bb commit beed6e4

File tree

13 files changed

+1615
-940
lines changed

13 files changed

+1615
-940
lines changed

sendgrid/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .version import __version__
2-
#v3 API
3-
from .sendgrid import SendGridAPIClient
4-
from .helpers.mail.mail import Email
1+
from .version import __version__ # noqa
2+
# v3 API
3+
from .sendgrid import SendGridAPIClient # noqa
4+
from .helpers.mail.mail import Email # noqa
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .config import *
2-
from .parse import *
1+
from .config import * # noqa
2+
from .parse import * # noqa

sendgrid/helpers/inbound/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
class Config(object):
77
"""All configuration for this app is loaded here"""
88
def __init__(self, **opts):
9-
if (os.environ.get('ENV') != 'prod'): # We are not in Heroku
9+
if os.environ.get('ENV') != 'prod': # We are not in Heroku
1010
self.init_environment()
1111

1212
"""Allow variables assigned in config.yml available the following variables
1313
via properties"""
14-
self.path = opts.get('path', os.path.abspath(os.path.dirname(__file__)))
14+
self.path = opts.get(
15+
'path', os.path.abspath(os.path.dirname(__file__))
16+
)
1517
with open(self.path + '/config.yml') as stream:
1618
config = yaml.load(stream)
1719
self._debug_mode = config['debug_mode']

sendgrid/helpers/inbound/parse.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@ def __init__(self, config, request):
1515
self._raw_payload = request.data
1616

1717
def key_values(self):
18-
"""Return a dictionary of key/values in the payload received from
19-
the webhook"""
18+
"""
19+
Return a dictionary of key/values in the payload received from
20+
the webhook
21+
"""
2022
key_values = {}
2123
for key in self.keys:
2224
if key in self.payload:
2325
key_values[key] = self.payload[key]
2426
return key_values
2527

2628
def get_raw_email(self):
27-
"""This only applies to raw payloads:
28-
https://sendgrid.com/docs/Classroom/Basics/Inbound_Parse_Webhook/setting_up_the_inbound_parse_webhook.html#-Raw-Parameters"""
29-
if 'email' in self.payload:
29+
"""
30+
This only applies to raw payloads:
31+
https://sendgrid.com/docs/Classroom/Basics/Inbound_Parse_Webhook/setting_up_the_inbound_parse_webhook.html#-Raw-Parameters
32+
"""
33+
if 'email' in self.payload:
3034
raw_email = email.message_from_string(self.payload['email'])
3135
return raw_email
32-
else:
36+
else:
3337
return None
3438

3539
def attachments(self):

sendgrid/helpers/inbound/send.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""A module for sending test SendGrid Inbound Parse messages
22
Usage: ./send.py [path to file containing test data]"""
33
import argparse
4-
import os
54
import sys
65
try:
76
from config import Config
8-
except:
7+
except ImportError:
98
# Python 3+, Travis
109
from sendgrid.helpers.inbound.config import Config
1110
from python_http_client import Client

sendgrid/helpers/mail/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .mail import *
1+
from .mail import * # noqa

0 commit comments

Comments
 (0)