Merge ~jslarraz/review-tools:run-black into review-tools:master
- Git
- lp:~jslarraz/review-tools
- run-black
- Merge into master
Proposed by
Jorge Sancho Larraz
Status: | Merged |
---|---|
Merged at revision: | d438d79718c3412236809685c25bdb086472b426 |
Proposed branch: | ~jslarraz/review-tools:run-black |
Merge into: | review-tools:master |
Diff against target: |
380 lines (+69/-37) 13 files modified
reviewtools/modules.py (+1/-0) reviewtools/overrides.py (+1/-1) reviewtools/sr_common.py (+5/-3) reviewtools/sr_functional.py (+1/-1) reviewtools/sr_lint.py (+2/-1) reviewtools/sr_security.py (+9/-5) reviewtools/tests/test_debversion.py (+1/-1) reviewtools/tests/test_email.py (+2/-2) reviewtools/tests/test_sr_declaration.py (+0/-3) reviewtools/tests/test_sr_functional.py (+4/-4) reviewtools/tests/test_sr_lint.py (+26/-10) reviewtools/tests/test_sr_security.py (+1/-1) reviewtools/tests/test_store.py (+16/-5) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Murray | Approve | ||
Review via email:
|
Commit message
As discussed we want to start enforcing black format in review-tools. This PR should only include format changes to adopt meet black format.
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/reviewtools/modules.py b/reviewtools/modules.py |
2 | index bd8be66..9b93f32 100644 |
3 | --- a/reviewtools/modules.py |
4 | +++ b/reviewtools/modules.py |
5 | @@ -56,6 +56,7 @@ def find_main_class(module_name): |
6 | fullpath = "%s/%s.py" % (dir, module_name) |
7 | if os.path.isfile(fullpath): |
8 | import importlib.util |
9 | + |
10 | spec = importlib.util.spec_from_file_location(module_name, fullpath) |
11 | if spec is None or spec.loader is None: |
12 | continue |
13 | diff --git a/reviewtools/overrides.py b/reviewtools/overrides.py |
14 | index a1db622..60d833b 100644 |
15 | --- a/reviewtools/overrides.py |
16 | +++ b/reviewtools/overrides.py |
17 | @@ -1271,7 +1271,7 @@ canonical_security = [ |
18 | "jorge.sancho.larraz@canonical.com", |
19 | "leo.barbosa@canonical.com", |
20 | "nishit.majithia@canonical.com", |
21 | - "paulo.smorigo@canonical.com" |
22 | + "paulo.smorigo@canonical.com", |
23 | ] |
24 | |
25 | canonical_server = ["christian.ehrhardt@canonical.com", "robie.basak@canonical.com"] |
26 | diff --git a/reviewtools/sr_common.py b/reviewtools/sr_common.py |
27 | index 4d33459..201a0dc 100644 |
28 | --- a/reviewtools/sr_common.py |
29 | +++ b/reviewtools/sr_common.py |
30 | @@ -286,9 +286,11 @@ class SnapReview(Review): |
31 | "posix-mq/plugs": "", |
32 | }, |
33 | "pwm": {"chip-number/slots": 0, "channel/slots": 0}, |
34 | - "qualcomm-ipc-router": {"address/slots": "", |
35 | - "qcipc/plugs": "", |
36 | - "qcipc/slots": ""}, |
37 | + "qualcomm-ipc-router": { |
38 | + "address/slots": "", |
39 | + "qcipc/plugs": "", |
40 | + "qcipc/slots": "", |
41 | + }, |
42 | "raw-volume": {"path/slots": ""}, |
43 | "sd-control": {"flavor/plugs": ""}, |
44 | "serial-port": { |
45 | diff --git a/reviewtools/sr_functional.py b/reviewtools/sr_functional.py |
46 | index 6ec2300..bbdc56b 100644 |
47 | --- a/reviewtools/sr_functional.py |
48 | +++ b/reviewtools/sr_functional.py |
49 | @@ -62,7 +62,7 @@ class SnapReviewFunctional(SnapReview): |
50 | |
51 | # read in current state |
52 | self.curr_state = {} |
53 | - for (line, item) in self.unsquashfs_lln_entries: |
54 | + for line, item in self.unsquashfs_lln_entries: |
55 | if item is None: |
56 | continue |
57 | |
58 | diff --git a/reviewtools/sr_lint.py b/reviewtools/sr_lint.py |
59 | index d8cdca4..c94340a 100644 |
60 | --- a/reviewtools/sr_lint.py |
61 | +++ b/reviewtools/sr_lint.py |
62 | @@ -3295,7 +3295,8 @@ class SnapReviewLint(SnapReview): |
63 | def check_mpris_slot_name(self): |
64 | """Check mpris slot name attribute is valid |
65 | |
66 | - https://github.com/snapcore/snapd/blob/55909123bcf261d11c9714b9245e9307f64f6891/interfaces/builtin/mpris.go#L215""" |
67 | + https://github.com/snapcore/snapd/blob/55909123bcf261d11c9714b9245e9307f64f6891/interfaces/builtin/mpris.go#L215 |
68 | + """ |
69 | if "slots" not in self.snap_yaml: |
70 | return |
71 | |
72 | diff --git a/reviewtools/sr_security.py b/reviewtools/sr_security.py |
73 | index 27f2ea8..5353208 100644 |
74 | --- a/reviewtools/sr_security.py |
75 | +++ b/reviewtools/sr_security.py |
76 | @@ -179,7 +179,10 @@ class SnapReviewSecurity(SnapReview): |
77 | |
78 | orig_stat = os.stat(orig) |
79 | resq_stat = os.stat(resq) |
80 | - debug_output += "\norig size: %d\nresq_size: %d" % (orig_stat.st_size, resq_stat.st_size) |
81 | + debug_output += "\norig size: %d\nresq_size: %d" % ( |
82 | + orig_stat.st_size, |
83 | + resq_stat.st_size, |
84 | + ) |
85 | |
86 | return debug_output |
87 | |
88 | @@ -376,8 +379,9 @@ class SnapReviewSecurity(SnapReview): |
89 | # If repacked package is smaller then original one, that means it's |
90 | # truncated with the minimum size. |
91 | if os.stat(fn).st_size == SNAP_MINIMUM_SIZE and ( |
92 | - os.stat(tmp_repack).st_size < os.stat(fn).st_size): |
93 | - with open(tmp_repack, 'ab') as f: |
94 | + os.stat(tmp_repack).st_size < os.stat(fn).st_size |
95 | + ): |
96 | + with open(tmp_repack, "ab") as f: |
97 | f.truncate(SNAP_MINIMUM_SIZE) |
98 | |
99 | (rc, out) = cmd(["sha512sum", tmp_repack]) |
100 | @@ -537,7 +541,7 @@ class SnapReviewSecurity(SnapReview): |
101 | readdir_pat = re.compile(r"^r.xr.xr.x") |
102 | errors = [] |
103 | |
104 | - for (line, item) in self.unsquashfs_lln_entries: |
105 | + for line, item in self.unsquashfs_lln_entries: |
106 | if item is None: |
107 | continue |
108 | |
109 | @@ -621,7 +625,7 @@ class SnapReviewSecurity(SnapReview): |
110 | if ref in self.base_declaration["slots"]: |
111 | ok = False |
112 | if pkgname in sec_iface_ref_matches_base_decl_overrides: |
113 | - for (aIface, aRef) in sec_iface_ref_matches_base_decl_overrides[ |
114 | + for aIface, aRef in sec_iface_ref_matches_base_decl_overrides[ |
115 | pkgname |
116 | ]: |
117 | if ( |
118 | diff --git a/reviewtools/tests/test_debversion.py b/reviewtools/tests/test_debversion.py |
119 | index 406c72e..f5190ec 100644 |
120 | --- a/reviewtools/tests/test_debversion.py |
121 | +++ b/reviewtools/tests/test_debversion.py |
122 | @@ -81,7 +81,7 @@ class TestDebVersion(TestCase): |
123 | ), |
124 | ] |
125 | print("") |
126 | - for (av, bv, expected) in versions: |
127 | + for av, bv, expected in versions: |
128 | print(" checking compare(%s, %s) == %d" % (av, bv, expected)) |
129 | a = DebVersion(av) |
130 | b = DebVersion(bv) |
131 | diff --git a/reviewtools/tests/test_email.py b/reviewtools/tests/test_email.py |
132 | index f665bc5..fa2e30f 100644 |
133 | --- a/reviewtools/tests/test_email.py |
134 | +++ b/reviewtools/tests/test_email.py |
135 | @@ -28,7 +28,7 @@ class TestEmail(TestCase): |
136 | ("Foo Bar <foo.bar@example.com>", "foo.bar@example.com"), |
137 | ("snaps@canonical.com", "snaps@canonical.com"), |
138 | ] |
139 | - for (addr, expected) in addresses: |
140 | + for addr, expected in addresses: |
141 | self.assertEqual(sanitize_addr(addr), expected) |
142 | |
143 | def test_check_sanitize_addr_invalid(self): |
144 | @@ -40,5 +40,5 @@ class TestEmail(TestCase): |
145 | ("@foo.bar", ""), |
146 | ("foo@@bar", ""), |
147 | ] |
148 | - for (addr, expected) in addresses: |
149 | + for addr, expected in addresses: |
150 | self.assertEqual(sanitize_addr(addr), expected) |
151 | diff --git a/reviewtools/tests/test_sr_declaration.py b/reviewtools/tests/test_sr_declaration.py |
152 | index cef3967..3d58737 100644 |
153 | --- a/reviewtools/tests/test_sr_declaration.py |
154 | +++ b/reviewtools/tests/test_sr_declaration.py |
155 | @@ -7729,7 +7729,6 @@ slots: |
156 | ], |
157 | ), |
158 | ]: |
159 | - |
160 | self.set_test_snap_yaml("plugs", plugs) |
161 | overrides = {"snap_decl_plugs": {"iface": {"%s" % (cstr): overrides}}} |
162 | c = SnapReviewDeclaration(self.test_name, overrides=overrides) |
163 | @@ -7835,7 +7834,6 @@ slots: |
164 | ], |
165 | ), |
166 | ]: |
167 | - |
168 | self.set_test_snap_yaml("plugs", plugs) |
169 | overrides = {"snap_decl_plugs": {"iface": {"%s" % (cstr): overrides}}} |
170 | c = SnapReviewDeclaration(self.test_name, overrides=overrides) |
171 | @@ -7911,7 +7909,6 @@ slots: |
172 | ], |
173 | ), |
174 | ]: |
175 | - |
176 | self.set_test_snap_yaml("plugs", plugs) |
177 | overrides = {"snap_decl_plugs": {"iface": {"%s" % (cstr): overrides}}} |
178 | c = SnapReviewDeclaration(self.test_name, overrides=overrides) |
179 | diff --git a/reviewtools/tests/test_sr_functional.py b/reviewtools/tests/test_sr_functional.py |
180 | index ebd760e..8b97757 100644 |
181 | --- a/reviewtools/tests/test_sr_functional.py |
182 | +++ b/reviewtools/tests/test_sr_functional.py |
183 | @@ -284,7 +284,7 @@ crw-rw-rw- 0/0 1, 3 2020-03-14 18:21 squashfs-root/dev/null |
184 | hdr, entries = unsquashfs_lln_parse(lln) |
185 | |
186 | state = {} |
187 | - for (line, item) in entries: |
188 | + for line, item in entries: |
189 | state[item[StatLLN.FILENAME]] = item |
190 | if "libc-2.31.so" in line: |
191 | state[item[StatLLN.FILENAME]]["symbols"] = { |
192 | @@ -297,7 +297,7 @@ crw-rw-rw- 0/0 1, 3 2020-03-14 18:21 squashfs-root/dev/null |
193 | |
194 | self.assertEqual(len(entries), len(serial)) |
195 | self.assertEqual(len(serial), 7) |
196 | - for (idx, map) in [ |
197 | + for idx, map in [ |
198 | (".", {"filetype": "d", "mode": "rwxr-xr-x", "owner": "0/0"}), |
199 | ("./bin", {"filetype": "d", "mode": "rwxr-xr-x", "owner": "0/0"}), |
200 | ("./bin/cat", {"filetype": "-", "mode": "rwxr-xr-x", "owner": "0/0"}), |
201 | @@ -378,7 +378,7 @@ crw-rw-rw- 0/0 1, 3 2020-03-14 18:21 squashfs-root/dev/null |
202 | c = SnapReviewFunctional(self.test_name) |
203 | |
204 | state = {} |
205 | - for (line, item) in entries: |
206 | + for line, item in entries: |
207 | state[item[StatLLN.FILENAME]] = item |
208 | |
209 | serial = c._serialize(state) |
210 | @@ -451,7 +451,7 @@ crw-rw-rw- 0/0 1, 3 2020-03-14 18:21 squashfs-root/dev/null |
211 | self.assertEqual(len(state), len(entries)) |
212 | self.assertEqual(len(state), 7) |
213 | |
214 | - for (idx, item) in [ |
215 | + for idx, item in [ |
216 | ( |
217 | ".", |
218 | { |
219 | diff --git a/reviewtools/tests/test_sr_lint.py b/reviewtools/tests/test_sr_lint.py |
220 | index 692e77e..46f141c 100644 |
221 | --- a/reviewtools/tests/test_sr_lint.py |
222 | +++ b/reviewtools/tests/test_sr_lint.py |
223 | @@ -1000,7 +1000,9 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
224 | def test_check_link_with_tilde(self): |
225 | """Test check_link""" |
226 | links = { |
227 | - "source-code": ["https://code.launchpad.net/~chromium-team/chromium-browser/+git/snap-from-source/+ref/stable"], |
228 | + "source-code": [ |
229 | + "https://code.launchpad.net/~chromium-team/chromium-browser/+git/snap-from-source/+ref/stable" |
230 | + ], |
231 | } |
232 | self.set_test_snap_yaml("links", links) |
233 | c = SnapReviewLint(self.test_name) |
234 | @@ -4753,7 +4755,7 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
235 | "lint-snap-v2:base_valid": { |
236 | "text": "(NEEDS REVIEW) snap grade (stable) does not match base grade (stable)" |
237 | } |
238 | - } |
239 | + }, |
240 | } |
241 | self.check_results(r, expected=expected) |
242 | name = c._get_check_name("base_valid") |
243 | @@ -5071,7 +5073,9 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
244 | expected_counts = {"info": 2, "warn": 0, "error": 0} |
245 | self.check_results(r, expected_counts) |
246 | |
247 | - def test_check_sockets_invalid_listen_stream_snap_user_data_without_user_daemon_scope(self): |
248 | + def test_check_sockets_invalid_listen_stream_snap_user_data_without_user_daemon_scope( |
249 | + self, |
250 | + ): |
251 | """Test check_apps_sockets() - invalid listen-stream SNAP_USER_DATA without user daemon-scope""" |
252 | self.set_test_snap_yaml( |
253 | "apps", |
254 | @@ -5088,8 +5092,12 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
255 | """Test check_apps_sockets() - valid listen-stream SNAP_USER_DATA with user daemon-scope""" |
256 | self.set_test_snap_yaml( |
257 | "apps", |
258 | - {"foo": {"sockets": {"sock1": {"listen-stream": "$SNAP_USER_DATA/sock"}}, |
259 | - "daemon-scope": "user"}}, |
260 | + { |
261 | + "foo": { |
262 | + "sockets": {"sock1": {"listen-stream": "$SNAP_USER_DATA/sock"}}, |
263 | + "daemon-scope": "user", |
264 | + } |
265 | + }, |
266 | ) |
267 | |
268 | c = SnapReviewLint(self.test_name) |
269 | @@ -5102,8 +5110,12 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
270 | """Test check_apps_sockets() - valid listen-stream SNAP_USER_COMMON with user daemon-scope""" |
271 | self.set_test_snap_yaml( |
272 | "apps", |
273 | - {"foo": {"sockets": {"sock1": {"listen-stream": "$SNAP_USER_COMMON/sock"}}, |
274 | - "daemon-scope": "user"}}, |
275 | + { |
276 | + "foo": { |
277 | + "sockets": {"sock1": {"listen-stream": "$SNAP_USER_COMMON/sock"}}, |
278 | + "daemon-scope": "user", |
279 | + } |
280 | + }, |
281 | ) |
282 | |
283 | c = SnapReviewLint(self.test_name) |
284 | @@ -5116,8 +5128,12 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
285 | """Test check_apps_sockets() - valid listen-stream XDG_RUNTIME_DIR with user daemon-scope""" |
286 | self.set_test_snap_yaml( |
287 | "apps", |
288 | - {"foo": {"sockets": {"sock1": {"listen-stream": "$XDG_RUNTIME_DIR/sock"}}, |
289 | - "daemon-scope": "user"}}, |
290 | + { |
291 | + "foo": { |
292 | + "sockets": {"sock1": {"listen-stream": "$XDG_RUNTIME_DIR/sock"}}, |
293 | + "daemon-scope": "user", |
294 | + } |
295 | + }, |
296 | ) |
297 | |
298 | c = SnapReviewLint(self.test_name) |
299 | @@ -6517,7 +6533,7 @@ class TestSnapReviewLint(sr_tests.TestSnapReview): |
300 | ("snap.foo.bar.ico", None), |
301 | ("snap.foo.bar", None), |
302 | ] |
303 | - for (fn, exreal) in valid: |
304 | + for fn, exreal in valid: |
305 | valid, real_fn = c._verify_icon_path(fn) |
306 | self.assertTrue(valid) |
307 | self.assertEqual(real_fn, exreal) |
308 | diff --git a/reviewtools/tests/test_sr_security.py b/reviewtools/tests/test_sr_security.py |
309 | index 9989747..de1cc44 100644 |
310 | --- a/reviewtools/tests/test_sr_security.py |
311 | +++ b/reviewtools/tests/test_sr_security.py |
312 | @@ -1071,7 +1071,7 @@ slots: |
313 | (pkg, "/test", "rwxrwxrwt", {"/test": "rwxrwxrwt"}, True), |
314 | (pkg, "/test", "rwxrwxrwt", {"/test": ["rwxrwxrwT", "rwxrwxrwt"]}, True), |
315 | ] |
316 | - for (p, f, m, override, exp) in tests: |
317 | + for p, f, m, override, exp in tests: |
318 | if p is not None: |
319 | sec_mode_overrides[p] = override |
320 | c = SnapReviewSecurity(self.test_name) |
321 | diff --git a/reviewtools/tests/test_store.py b/reviewtools/tests/test_store.py |
322 | index cd6c3d1..5c1b8cd 100644 |
323 | --- a/reviewtools/tests/test_store.py |
324 | +++ b/reviewtools/tests/test_store.py |
325 | @@ -594,7 +594,8 @@ class TestStore(TestCase): |
326 | self, |
327 | ): |
328 | """Test get_package_revisions() - parts/stage-packages and |
329 | - primed-stage-packages are None has no security notices if no usn for build-pkgs""" |
330 | + primed-stage-packages are None has no security notices if no usn for build-pkgs |
331 | + """ |
332 | for i in range(len(self.store_db[0]["revisions"])): |
333 | m = yaml.load( |
334 | self.store_db[0]["revisions"][i]["manifest_yaml"], |
335 | @@ -1211,7 +1212,12 @@ class TestStore(TestCase): |
336 | |
337 | def test_check_get_secnots_ignore_pockets(self): |
338 | """Test get_secnots_for_manifest() - ignore_pockets""" |
339 | - for ignore_pockets in [[], ["esm-apps"], ["esm-apps/focal"], ["esm-apps/jammy"]]: |
340 | + for ignore_pockets in [ |
341 | + [], |
342 | + ["esm-apps"], |
343 | + ["esm-apps/focal"], |
344 | + ["esm-apps/jammy"], |
345 | + ]: |
346 | m = yaml.load( |
347 | self.store_esm_apps_db[0]["revisions"][0]["manifest_yaml"], |
348 | Loader=yaml.SafeLoader, |
349 | @@ -2174,7 +2180,7 @@ class TestStore(TestCase): |
350 | ("4.4.0-161", "4.4.0.161.999999"), |
351 | ("4.4.0-140-1", "4.4.0.140.999999"), |
352 | ] |
353 | - for (v, expected) in tests: |
354 | + for v, expected in tests: |
355 | res = store.convert_canonical_kernel_version(v) |
356 | self.assertEqual(res, expected) |
357 | |
358 | @@ -2190,7 +2196,7 @@ class TestStore(TestCase): |
359 | ("1.2-3+git1234ubuntu0.1", "1.2-3+git1234ubuntu0.1"), |
360 | ("1.2-3+git1234ubuntu0.1+deadbeef", "1.2-3+git1234ubuntu0.1"), |
361 | ] |
362 | - for (v, expected) in tests: |
363 | + for v, expected in tests: |
364 | res = store.convert_canonical_app_version(v) |
365 | self.assertEqual(res, expected) |
366 | |
367 | @@ -2600,7 +2606,12 @@ class TestStore(TestCase): |
368 | def test_check_get_package_revisions_ignore_pockets(self): |
369 | """Test get_package_revisions() - ignore_pockets=esm-apps""" |
370 | errors = {} |
371 | - for ignore_pockets in [[], ["esm-apps"], ["esm-apps/focal"], ["esm-apps/jammy"]]: |
372 | + for ignore_pockets in [ |
373 | + [], |
374 | + ["esm-apps"], |
375 | + ["esm-apps/focal"], |
376 | + ["esm-apps/jammy"], |
377 | + ]: |
378 | with self.subTest(): |
379 | res = store.get_pkg_revisions( |
380 | read_file_as_json_dict("./tests/test-store-unittest-esm-apps.db")[ |
LGTM - as seen in the lpci test log:
:: ./run-black __init_ _.py available. py common. py debversion. py email.py modules. py overrides. py rr_common. py sr_common. py sr_declaration. py sr_functional. py sr_lint. py sr_security. py sr_skeleton. py sr_tests. py store.py usn.py tests/_ _init__ .py tests/test_ available. py tests/test_ bbb_example_ sr_skeleton. py tests/test_ common. py tests/test_ debversion. py tests/test_ email.py tests/test_ modules. py tests/test_ sr_common. py tests/test_ sr_declaration. py tests/test_ sr_functional. py tests/test_ sr_lint. py tests/test_ sr_security. py tests/test_ store.py tests/test_ usn.py tests/utils. py snap-declaratio n base-declaratio n updates- available updates- available check-declarati on check-lint check-security check-skeleton verify- declaration
:: = black =
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./reviewtools/
:: Checking ./bin/snap-review
:: Checking ./bin/create-
:: Checking ./bin/dump-tool
:: Checking ./bin/get-
:: Checking ./bin/store-query
:: Checking ./bin/rock-
:: Checking ./bin/snap-
:: Checking ./bin/snap-
:: Checking ./bin/snap-
:: Checking ./bin/snap-
:: Checking ./bin/snap-
:: Checking ./bin/snap-