Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix a number of flake8 errors #4082

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4082.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean up some bits of code which were flagged by the linter
2 changes: 1 addition & 1 deletion scripts-dev/tail-synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
row.name: row.position
for row in replicate(server, {"streams": "-1"})["streams"].rows
}
except requests.exceptions.ConnectionError as e:
except requests.exceptions.ConnectionError:
time.sleep(0.1)

while True:
Expand Down
3 changes: 2 additions & 1 deletion scripts/synapse_port_db
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ class Porter(object):

try:
yield self.postgres_store.runInteraction("alter_table", alter_table)
except Exception as e:
except Exception:
# On Error Resume Next
pass

yield self.postgres_store.runInteraction(
Expand Down
17 changes: 8 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ ignore =
pylint.cfg
tox.ini

[pep8]
max-line-length = 90
# W503 requires that binary operators be at the end, not start, of lines. Erik
# doesn't like it. E203 is contrary to PEP8. E731 is silly.
ignore = W503,E203,E731

[flake8]
# note that flake8 inherits the "ignore" settings from "pep8" (because it uses
# pep8 to do those checks), but not the "max-line-length" setting
max-line-length = 90
ignore=W503,E203,E731

# see https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
# for error codes. The ones we ignore are:
# W503: line break before binary operator
# W504: line break after binary operator
# E203: whitespace before ':' (which is contrary to pep8?)
# E731: do not assign a lambda expression, use a def
ignore=W503,W504,E203,E731

[isort]
line_length = 89
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def read_config(self, config):
def default_config(self, **kwargs):
media_store = self.default_path("media_store")
uploads_path = self.default_path("uploads")
return """
return r"""
# Directory where uploaded images and attachments are stored.
media_store_path: "%(media_store)s"

Expand Down
2 changes: 1 addition & 1 deletion synapse/crypto/keyclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def fetch_server_key(server_name, tls_client_options_factory, path=KEY_API_V1):
raise IOError("Cannot get key for %r" % server_name)
except (ConnectError, DomainError) as e:
logger.warn("Error getting key for %r: %s", server_name, e)
except Exception as e:
except Exception:
logger.exception("Error getting key for %r", server_name)
raise IOError("Cannot get key for %r" % server_name)

Expand Down
2 changes: 1 addition & 1 deletion synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def on_edu(self, edu_type, origin, content):
yield handler(origin, content)
except SynapseError as e:
logger.info("Failed to handle edu %r: %r", edu_type, e)
except Exception as e:
except Exception:
logger.exception("Failed to handle edu %r", edu_type)

def on_query(self, query_type, args):
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/v2_alpha/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AuthRestServlet(RestServlet):
cannot be handled in the normal flow (with requests to the same endpoint).
Current use is for web fallback auth.
"""
PATTERNS = client_v2_patterns("/auth/(?P<stagetype>[\w\.]*)/fallback/web")
PATTERNS = client_v2_patterns(r"/auth/(?P<stagetype>[\w\.]*)/fallback/web")

def __init__(self, hs):
super(AuthRestServlet, self).__init__()
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def summarize_paragraphs(text_nodes, min_size=200, max_size=500):
# This splits the paragraph into words, but keeping the
# (preceeding) whitespace intact so we can easily concat
# words back together.
for match in re.finditer("\s*\S+", description):
for match in re.finditer(r"\s*\S+", description):
word = match.group()

# Keep adding words while the total length is less than
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def find_next_generated_user_id_localpart(self):
def _find_next_generated_user_id(txn):
txn.execute("SELECT name FROM users")

regex = re.compile("^@(\d+):")
regex = re.compile(r"^@(\d+):")

found = set()

Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ def assert_log_filename_is(self, log_config_file, expected):
with open(log_config_file) as f:
config = f.read()
# find the 'filename' line
matches = re.findall("^\s*filename:\s*(.*)$", config, re.M)
matches = re.findall(r"^\s*filename:\s*(.*)$", config, re.M)
self.assertEqual(1, len(matches))
self.assertEqual(matches[0], expected)
4 changes: 2 additions & 2 deletions tests/events/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_event_fields_works_with_dot_keys(self):
room_id="!foo:bar",
content={"key.with.dots": {}},
),
["content.key\.with\.dots"],
[r"content.key\.with\.dots"],
),
{"content": {"key.with.dots": {}}},
)
Expand All @@ -172,7 +172,7 @@ def test_event_fields_works_with_nested_dot_keys(self):
"nested.dot.key": {"leaf.key": 42, "not_me_either": 1},
},
),
["content.nested\.dot\.key.leaf\.key"],
[r"content.nested\.dot\.key.leaf\.key"],
),
{"content": {"nested.dot.key": {"leaf.key": 42}}},
)
Expand Down