Skip to content

Commit

Permalink
Fix Flake8 lints
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Callahan <danc@element.io>
  • Loading branch information
callahad committed May 28, 2021
1 parent 68b0c19 commit 643ac4a
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 30 deletions.
8 changes: 4 additions & 4 deletions sydent/db/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def storeAccount(self, user_id, creation_ts, consent_version):
:type consent_version: str or None
"""
cur = self.sydent.db.cursor()
res = cur.execute(
cur.execute(
"insert or ignore into accounts (user_id, created_ts, consent_version) "
"values (?, ?, ?)",
(user_id, creation_ts, consent_version),
Expand All @@ -76,7 +76,7 @@ def setConsentVersion(self, user_id, consent_version):
:type consent_version: unicode or None
"""
cur = self.sydent.db.cursor()
res = cur.execute(
cur.execute(
"update accounts set consent_version = ? where user_id = ?",
(consent_version, user_id),
)
Expand All @@ -92,7 +92,7 @@ def addToken(self, user_id, token):
:type token: unicode
"""
cur = self.sydent.db.cursor()
res = cur.execute(
cur.execute(
"insert into tokens (user_id, token) values (?, ?)",
(user_id, token),
)
Expand All @@ -106,7 +106,7 @@ def delToken(self, token):
:type token: unicode
"""
cur = self.sydent.db.cursor()
res = cur.execute(
cur.execute(
"delete from tokens where token = ?",
(token,),
)
Expand Down
6 changes: 3 additions & 3 deletions sydent/db/sqlitedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _createSchema(self):
try:
logger.info("Importing %s", scriptPath)
c.executescript(fp.read())
except:
except Exception:
logger.error("Error importing %s", scriptPath)
raise
fp.close()
Expand Down Expand Up @@ -212,12 +212,12 @@ def _upgradeSchema(self):

def _getSchemaVersion(self):
cur = self.db.cursor()
res = cur.execute("PRAGMA user_version")
cur.execute("PRAGMA user_version")
row = cur.fetchone()
return row[0]

def _setSchemaVersion(self, ver):
cur = self.db.cursor()
# NB. pragma doesn't support variable substitution so we
# do it in python (as a decimal so we don't risk SQL injection)
res = cur.execute("PRAGMA user_version = %d" % (ver,))
cur.execute("PRAGMA user_version = %d" % (ver,))
2 changes: 1 addition & 1 deletion sydent/db/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def addAgreedUrls(self, user_id, urls):
:type urls: list[unicode]
"""
cur = self.sydent.db.cursor()
res = cur.executemany(
cur.executemany(
"insert or ignore into accepted_terms_urls (user_id, url) values (?, ?)",
((user_id, u) for u in urls),
)
Expand Down
1 change: 0 additions & 1 deletion sydent/http/federation_tls_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from twisted.internet import ssl
from twisted.internet.interfaces import IOpenSSLClientConnectionCreator
from twisted.internet.abstract import isIPAddress, isIPv6Address
from twisted.internet._sslverify import ClientTLSOptions


def _tolerateErrors(wrapped):
Expand Down
4 changes: 2 additions & 2 deletions sydent/http/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from io import BytesIO

from twisted.internet import defer
from twisted.web.client import FileBodyProducer, Agent, readBody
from twisted.web.client import FileBodyProducer, Agent
from twisted.web.http_headers import Headers

from sydent.http.blacklisting_reactor import BlacklistingReactorWrapper
Expand Down 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:
logger.exception("Error parsing JSON from %s", uri)
raise
defer.returnValue(json_body)
Expand Down
2 changes: 1 addition & 1 deletion sydent/http/matrixfederationagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from twisted.web.http_headers import Headers
from twisted.web.iweb import IAgent

from sydent.http.httpcommon import BodyExceededMaxSize, read_body_with_max_size
from sydent.http.httpcommon import read_body_with_max_size
from sydent.http.srvresolver import SrvResolver, pick_server_from_list
from sydent.util import json_decoder
from sydent.util.ttlcache import TTLCache
Expand Down
2 changes: 1 addition & 1 deletion sydent/http/servlets/blindlysignstuffservlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def render_POST(self, request):
"ed25519", "0", private_key_base64
)
signed = signedjson.sign.sign_json(to_sign, self.server_name, private_key)
except:
except Exception:
logger.exception("signing failed")
raise MatrixRestError(500, "M_UNKNOWN", "Internal Server Error")

Expand Down
2 changes: 1 addition & 1 deletion sydent/http/servlets/emailservlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def render_GET(self, request):
resp = None
try:
resp = self.do_validate_request(request)
except:
except Exception:
pass
if resp and "success" in resp and resp["success"]:
msg = "Verification successful! Please return to your Matrix client to continue."
Expand Down
4 changes: 2 additions & 2 deletions sydent/http/servlets/lookupservlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import logging
import signedjson.sign

from sydent.http.servlets import get_args, jsonwrap, send_cors, MatrixRestError
from sydent.http.servlets import get_args, jsonwrap, send_cors
from sydent.util import json_decoder


Expand Down Expand Up @@ -61,7 +61,7 @@ def render_GET(self, request):
return {}

sgassoc = json_decoder.decode(sgassoc)
if not self.sydent.server_name in sgassoc["signatures"]:
if self.sydent.server_name not in sgassoc["signatures"]:
# We have not yet worked out what the proper trust model should be.
#
# Maybe clients implicitly trust a server they talk to (and so we
Expand Down
3 changes: 1 addition & 2 deletions sydent/http/servlets/registerservlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
from twisted.internet import defer

import logging
import json
from six.moves import urllib

from sydent.http.servlets import get_args, jsonwrap, deferjsonwrap, send_cors
from sydent.http.servlets import get_args, deferjsonwrap, send_cors
from sydent.http.httpclient import FederationHttpClient
from sydent.users.tokens import issueToken
from sydent.util.stringutils import is_valid_matrix_server_name
Expand Down
2 changes: 1 addition & 1 deletion sydent/http/servlets/replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def render_POST(self, request):
logger.info(
"Stored association origin ID %s from %s", originId, peer.servername
)
except:
except Exception:
failedIds.append(originId)
logger.warn(
"Failed to verify signed association from %s with origin ID %s",
Expand Down
1 change: 0 additions & 1 deletion sydent/http/servlets/threepidunbindservlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.
from __future__ import absolute_import

import json
import logging

from sydent.hs_federation.verifier import NoAuthenticationError, InvalidServerName
Expand Down
1 change: 0 additions & 1 deletion sydent/replication/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion sydent/replication/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def verifySignedAssociation(self, assoc):
:param assoc: A signed association.
:type assoc: dict[any, any]
"""
if not "signatures" in assoc:
if "signatures" not in assoc:
raise NoSignaturesException()

key_ids = signedjson.sign.signature_ids(assoc, self.servername)
Expand Down
2 changes: 0 additions & 2 deletions sydent/util/emailutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
else:
from html import escape

import email.utils

from sydent.util import time_msec
from sydent.util.tokenutils import generateAlphanumericTokenOfLength

Expand Down
1 change: 0 additions & 1 deletion tests/test_blacklisting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


from mock import patch
from netaddr import IPSet
from twisted.internet import defer
from twisted.internet.error import DNSLookupError
from twisted.test.proto_helpers import StringTransport
Expand Down
6 changes: 1 addition & 5 deletions tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
# limitations under the License.

import os.path
from mock import Mock, patch
from mock import patch

from twisted.web.client import Response
from twisted.trial import unittest

from sydent.db.invite_tokens import JoinTokenStore
from sydent.http.httpclient import FederationHttpClient
from sydent.http.servlets.store_invite_servlet import StoreInviteServlet
from tests.utils import make_request, make_sydent


Expand Down

0 comments on commit 643ac4a

Please sign in to comment.