From 48802310eeef594474638cecf22b9a29abdbab6f Mon Sep 17 00:00:00 2001 From: ankitdobhal Date: Thu, 18 Mar 2021 07:06:08 -0400 Subject: [PATCH] Fixed code quality issues - Consider merging 'isinstance' calls - Remove 'redundant' call - Use 'sys.exit()' calls Signed-off-by: ankitdobhal --- changelog.d/9649.misc | 1 + scripts/move_remote_media_to_new_store.py | 2 +- synapse/push/httppusher.py | 2 +- synapse/util/frozenutils.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog.d/9649.misc diff --git a/changelog.d/9649.misc b/changelog.d/9649.misc new file mode 100644 index 000000000000..58c5fd0537fc --- /dev/null +++ b/changelog.d/9649.misc @@ -0,0 +1 @@ +Fixed some antipattern issues to improve code quality. diff --git a/scripts/move_remote_media_to_new_store.py b/scripts/move_remote_media_to_new_store.py index ab2e76338675..8477955a906d 100755 --- a/scripts/move_remote_media_to_new_store.py +++ b/scripts/move_remote_media_to_new_store.py @@ -51,7 +51,7 @@ def main(src_repo, dest_repo): parts = line.split("|") if len(parts) != 2: print("Unable to parse input line %s" % line, file=sys.stderr) - exit(1) + sys.exit(1) move_media(parts[0], parts[1], src_paths, dest_paths) diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py index eb6de8ba72b1..026134ae260a 100644 --- a/synapse/push/httppusher.py +++ b/synapse/push/httppusher.py @@ -290,7 +290,7 @@ async def _process_one(self, push_action: dict) -> bool: if rejected is False: return False - if isinstance(rejected, list) or isinstance(rejected, tuple): + if isinstance(rejected, (list, tuple)): for pk in rejected: if pk != self.pushkey: # for sanity, we only remove the pushkey if it diff --git a/synapse/util/frozenutils.py b/synapse/util/frozenutils.py index 5f7a6dd1d3f7..5ca2e71e604e 100644 --- a/synapse/util/frozenutils.py +++ b/synapse/util/frozenutils.py @@ -36,7 +36,7 @@ def freeze(o): def unfreeze(o): if isinstance(o, (dict, frozendict)): - return dict({k: unfreeze(v) for k, v in o.items()}) + return {k: unfreeze(v) for k, v in o.items()} if isinstance(o, (bytes, str)): return o