Skip to content

Commit

Permalink
flake8 linting of a few misc files in sydent/
Browse files Browse the repository at this point in the history
  • Loading branch information
Shay committed May 27, 2021
1 parent ac60a71 commit f9672ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion sydent/http/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_json(self, uri, max_size=None):
try:
# json.loads doesn't allow bytes in Python 3.5
json_body = json_decoder.decode(body.decode("UTF-8"))
except Exception as e:
except Exception as e: # noqa: F841
logger.exception("Error parsing JSON from %s", uri)
raise
defer.returnValue(json_body)
Expand Down
20 changes: 12 additions & 8 deletions sydent/validators/emailvalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def requestToken(
brand=None,
):
"""
Creates or retrieves a validation session and sends an email to the corresponding
email address with a token to use to verify the association.
Creates or retrieves a validation session and sends an email to the
corresponding email address with a token to use to verify the association.
:param emailAddress: The email address to send the email to.
:type emailAddress: unicode
Expand Down Expand Up @@ -77,7 +77,8 @@ def requestToken(

if int(valSession.sendAttemptNumber) >= int(sendAttempt):
logger.info(
"Not mailing code because current send attempt (%d) is not less than given send attempt (%s)",
"Not mailing code because current send attempt "
"(%d) is not less than given send attempt (%s)",
int(sendAttempt),
int(valSession.sendAttemptNumber),
)
Expand Down Expand Up @@ -118,11 +119,14 @@ def makeValidateLink(self, valSession, clientSecret, nextLink):
:rtype: unicode
"""
base = self.sydent.cfg.get("http", "client_http_base")
link = "%s/_matrix/identity/api/v1/validate/email/submitToken?token=%s&client_secret=%s&sid=%d" % (
base,
urllib.parse.quote(valSession.token),
urllib.parse.quote(clientSecret),
valSession.id,
link = (
"%s/_matrix/identity/api/v1/validate/email/submitToken?"
"token=%s&client_secret=%s&sid=%d" % (
base,
urllib.parse.quote(valSession.token),
urllib.parse.quote(clientSecret),
valSession.id,
)
)
if nextLink:
# manipulate the nextLink to add the sid, because
Expand Down
12 changes: 8 additions & 4 deletions sydent/validators/msisdnvalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ def __init__(self, sydent):
parts = origString.split(":")
if len(parts) != 2:
raise Exception(
"Originators must be in form: long:<number>, short:<number> or alpha:<text>, separated by commas"
"Originators must be in form: long:<number>, "
"short:<number> or alpha:<text>, separated by commas"
)
if parts[0] not in ["long", "short", "alpha"]:
raise Exception(
"Invalid originator type: valid types are long, short and alpha"
"Invalid originator type: "
"valid types are long, short and alpha"
)
self.originators[country].append(
{
Expand All @@ -76,7 +78,8 @@ def __init__(self, sydent):
def requestToken(self, phoneNumber, clientSecret, sendAttempt, brand=None):
"""
Creates or retrieves a validation session and sends an text message to the
corresponding phone number address with a token to use to verify the association.
corresponding phone number address with a token to use to verify the
association.
:param phoneNumber: The phone number to send the email to.
:type phoneNumber: phonenumbers.PhoneNumber
Expand Down Expand Up @@ -109,7 +112,8 @@ def requestToken(self, phoneNumber, clientSecret, sendAttempt, brand=None):

if int(valSession.sendAttemptNumber) >= int(sendAttempt):
logger.info(
"Not texting code because current send attempt (%d) is not less than given send attempt (%s)",
"Not texting code because current send attempt "
"(%d) is not less than given send attempt (%s)",
int(sendAttempt),
int(valSession.sendAttemptNumber),
)
Expand Down

0 comments on commit f9672ef

Please sign in to comment.