Fixed code misc. quality issues (#9649)

- Merge 'isinstance' calls.
- Remove unnecessary dict call outside of comprehension.
- Use 'sys.exit()' calls.
pull/9665/head
Ankit Dobhal 2021-03-22 20:48:13 +05:30 committed by GitHub
parent d600d4506b
commit d66f9070cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 3 deletions

1
changelog.d/9649.misc Normal file
View File

@ -0,0 +1 @@
Fixed some antipattern issues to improve code quality.

View File

@ -51,7 +51,7 @@ def main(src_repo, dest_repo):
parts = line.split("|") parts = line.split("|")
if len(parts) != 2: if len(parts) != 2:
print("Unable to parse input line %s" % line, file=sys.stderr) 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) move_media(parts[0], parts[1], src_paths, dest_paths)

View File

@ -290,7 +290,7 @@ class HttpPusher(Pusher):
if rejected is False: if rejected is False:
return False return False
if isinstance(rejected, list) or isinstance(rejected, tuple): if isinstance(rejected, (list, tuple)):
for pk in rejected: for pk in rejected:
if pk != self.pushkey: if pk != self.pushkey:
# for sanity, we only remove the pushkey if it # for sanity, we only remove the pushkey if it

View File

@ -36,7 +36,7 @@ def freeze(o):
def unfreeze(o): def unfreeze(o):
if isinstance(o, (dict, frozendict)): 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)): if isinstance(o, (bytes, str)):
return o return o