Merge ~barryprice/spade/+git/spade:flake8 into spade:master

Proposed by Barry Price
Status: Needs review
Proposed branch: ~barryprice/spade/+git/spade:flake8
Merge into: spade:master
Prerequisite: ~barryprice/spade/+git/spade:master
Diff against target: 153 lines (+15/-14)
5 files modified
spade/AzureBucket.py (+2/-2)
spade/S3Bucket.py (+3/-3)
spade/Spade.py (+5/-5)
spade/SwiftBucket.py (+3/-3)
spade/spade.py (+2/-1)
Reviewer Review Type Date Requested Status
Haw Loeung +1 Approve
Review via email: mp+394572@code.launchpad.net

This proposal supersedes a proposal from 2020-11-27.

Commit message

Address all Flake8 errors bar complexity (noqa: C901)

To post a comment you must log in.
Revision history for this message
Haw Loeung (hloeung) wrote :

LGTM

review: Approve (+1)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/spade/AzureBucket.py b/spade/AzureBucket.py
2index 92bf430..0f7a62d 100644
3--- a/spade/AzureBucket.py
4+++ b/spade/AzureBucket.py
5@@ -239,7 +239,7 @@ class AzureBucket():
6 newStandardMetadata[k] = v
7 if not overwrite:
8 for k, v in m.userMetadata.items():
9- newUserMetadata[USER_META_PREFIX + k] = v
10+ newUserMetadata[USER_META_PREFIX + k] = v
11
12 # Add new ones
13 for k, v in metadata.items():
14@@ -318,7 +318,7 @@ class AzureBucket():
15 body=xml,
16 method="PUT")
17 if not response.get("status") == "201":
18- raise BucketError("Azure Failed to upload blocklist")
19+ raise BucketError("Azure Failed to upload blocklist")
20 return
21
22 def putObject(self, bucketName, objectName, src, size, blockSize=DEFAULT_BLOCKSIZE):
23diff --git a/spade/S3Bucket.py b/spade/S3Bucket.py
24index 90e6a84..6d3036e 100644
25--- a/spade/S3Bucket.py
26+++ b/spade/S3Bucket.py
27@@ -61,7 +61,7 @@ class S3Bucket():
28 {'name': 'us-west-1', 'endpoint': 's3-us-west-1.amazonaws.com'},
29 {'name': 'us-west-2', 'endpoint': 's3-us-west-2.amazonaws.com'},
30 {'name': 'us-east-1', 'endpoint': 's3.amazonaws.com'},
31- ]
32+ ]
33
34 self.base_fields = set(['content-length', 'content-language', 'content-disposition',
35 'content-encoding', 'expires', 'content-md5', 'last-modified',
36@@ -325,7 +325,7 @@ class S3Bucket():
37 else:
38 return aclData["s3_id"]
39
40- def getAcls(self, bucketName, objectName=None):
41+ def getAcls(self, bucketName, objectName=None): # noqa: C901
42 self.confirmRegion(bucketName)
43 try:
44 bucket = self.s3.get_bucket(bucketName)
45@@ -366,7 +366,7 @@ class S3Bucket():
46
47 return acls
48
49- def setAcls(self, bucketName, acls, objectName=None):
50+ def setAcls(self, bucketName, acls, objectName=None): # noqa: C901
51 self.confirmRegion(bucketName)
52 try:
53 bucket = self.s3.get_bucket(bucketName)
54diff --git a/spade/Spade.py b/spade/Spade.py
55index b33edb0..b8f4b12 100644
56--- a/spade/Spade.py
57+++ b/spade/Spade.py
58@@ -69,7 +69,7 @@ class Bucket():
59 raise BucketError("Data is not in bzip2 format")
60 else:
61 raise BucketError("Unknown IO error")
62- except lzma.LZMAError as e:
63+ except lzma.LZMAError:
64 if "Input format not supported by decoder":
65 raise BucketError("Data is not in xz/lzma format")
66 else:
67@@ -150,7 +150,7 @@ class Bucket():
68 ret.output.append(retElement)
69 return ret
70
71- def ls(self, rawArgs):
72+ def ls(self, rawArgs): # noqa: C901
73 ret = Result()
74 parser = argparse.ArgumentParser(description="Bucket ls")
75 parser.add_argument("-l", dest="long", action="store_true")
76@@ -237,7 +237,7 @@ class Bucket():
77 ret.output = [data.decode("utf-8")]
78 f.close()
79
80- def grep(self, rawArgs):
81+ def grep(self, rawArgs): # noqa: C901
82 ret = Result()
83 parser = argparse.ArgumentParser(description="Bucket grep")
84 parser.add_argument("-e", dest="regex", action="store_true", help="Allow regexes in the search")
85@@ -374,7 +374,7 @@ class Bucket():
86 ret.output.append(e)
87 return ret
88
89- def cp(self, rawArgs):
90+ def cp(self, rawArgs): # noqa: C901
91 ret = Result()
92 parser = argparse.ArgumentParser(description="Bucket cp")
93 parser.add_argument(dest="src")
94@@ -581,7 +581,7 @@ class Bucket():
95
96 # FIXME: Need to pass add/remove to bucket acl functions instead of
97 # just the processed acls list
98- def acls(self, rawArgs):
99+ def acls(self, rawArgs): # noqa: C901
100 ret = Result()
101 parser = argparse.ArgumentParser(description="Bucket ACLs")
102 parser.add_argument("-a", "--add", dest="add", action="append", default=[])
103diff --git a/spade/SwiftBucket.py b/spade/SwiftBucket.py
104index f49f2b9..2125b85 100644
105--- a/spade/SwiftBucket.py
106+++ b/spade/SwiftBucket.py
107@@ -108,7 +108,7 @@ class SwiftBucket():
108 co.rawMetadata[k] = v
109 return co
110
111- def setBucketMetadata(self, bucketName, metadata, overwrite=False):
112+ def setBucketMetadata(self, bucketName, metadata, overwrite=False): # noqa: C901
113 systemMetadata = ["content-type", "x-container-bytes-used",
114 "x-container-object-count:", "x-timestamp"]
115 newMetadata = {}
116@@ -237,7 +237,7 @@ class SwiftBucket():
117 headers = {
118 'x-object-manifest': manifest,
119 'x-object-meta-mtime': mtime,
120- }
121+ }
122 try:
123 self.swift.put_object(bucketName,
124 objectName,
125@@ -265,7 +265,7 @@ class SwiftBucket():
126 def open(self, bucketName, objectName, blockSize=DEFAULT_BLOCKSIZE):
127 return ObjectIO(self, bucketName, objectName, blockSize)
128
129- def deleteObject(self, bucketName, objectName):
130+ def deleteObject(self, bucketName, objectName): # noqa: C901
131 try:
132 metadata = self.getObjectMetadata(bucketName, objectName)
133 except BucketError:
134diff --git a/spade/spade.py b/spade/spade.py
135index c000805..1b5811c 100755
136--- a/spade/spade.py
137+++ b/spade/spade.py
138@@ -8,7 +8,7 @@ import argparse
139 from spade.Spade import Bucket
140
141
142-def main():
143+def main(): # noqa: C901
144 parser = argparse.ArgumentParser(description="Bucket manipulation")
145 parser.add_argument("--configfile", dest="configfile", help="Config file")
146 parser.add_argument(dest="cmd")
147@@ -157,5 +157,6 @@ def main():
148 else:
149 print("Unknown command {}".format(args.cmd), file=sys.stderr)
150
151+
152 if __name__ == "__main__":
153 main()

Subscribers

People subscribed via source and target branches

to all changes: