Merge ~cjwatson/launchpad-buildd:flake8 into launchpad-buildd:master
- Git
- lp:~cjwatson/launchpad-buildd
- flake8
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 2faae1482f1a26e354f9658ba8e554b4e272d765 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad-buildd:flake8 |
Merge into: | launchpad-buildd:master |
Diff against target: |
907 lines (+211/-168) 27 files modified
.pre-commit-config.yaml (+13/-0) bin/buildrecipe (+21/-19) bin/test_buildd_generatetranslationtemplates (+0/-5) bin/test_buildd_recipe (+5/-6) buildd-genconfig (+36/-31) debian/changelog (+6/-0) debian/upgrade-config (+28/-10) lpbuildd/binarypackage.py (+17/-13) lpbuildd/builder.py (+4/-4) lpbuildd/check_implicit_pointer_functions.py (+7/-7) lpbuildd/oci.py (+1/-2) lpbuildd/proxy.py (+5/-5) lpbuildd/sourcepackagerecipe.py (+2/-3) lpbuildd/target/build_charm.py (+0/-1) lpbuildd/target/lxd.py (+2/-2) lpbuildd/target/operation.py (+0/-2) lpbuildd/target/tests/test_lxd.py (+3/-2) lpbuildd/target/vcs.py (+2/-1) lpbuildd/tests/fakebuilder.py (+4/-4) lpbuildd/tests/oci_tarball.py (+4/-6) lpbuildd/tests/test_binarypackage.py (+15/-15) lpbuildd/tests/test_buildrecipe.py (+29/-25) lpbuildd/tests/test_charm.py (+2/-1) lpbuildd/tests/test_harness.py (+1/-1) lpbuildd/tests/test_sourcepackagerecipe.py (+1/-1) lpbuildd/tests/test_util.py (+2/-1) setup.py (+1/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jürgen Gmach | Approve | ||
Review via email: mp+412903@code.launchpad.net |
Commit message
Add basic pre-commit configuration and apply flake8
Description of the change
To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote : | # |
As mentioned at standup I have no particular objection to the occasional noqa comment, but in this case I found some alternative approaches that avoid line length issues while (IMO) not compromising readability.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml |
2 | new file mode 100644 |
3 | index 0000000..8970c21 |
4 | --- /dev/null |
5 | +++ b/.pre-commit-config.yaml |
6 | @@ -0,0 +1,13 @@ |
7 | +repos: |
8 | +- repo: https://github.com/pre-commit/pre-commit-hooks |
9 | + rev: v4.0.1 |
10 | + hooks: |
11 | + - id: check-added-large-files |
12 | + - id: check-merge-conflict |
13 | + - id: check-xml |
14 | + - id: check-yaml |
15 | + - id: debug-statements |
16 | +- repo: https://github.com/PyCQA/flake8 |
17 | + rev: 4.0.1 |
18 | + hooks: |
19 | + - id: flake8 |
20 | diff --git a/bin/buildrecipe b/bin/buildrecipe |
21 | index 4d04c4f..5dcab4a 100755 |
22 | --- a/bin/buildrecipe |
23 | +++ b/bin/buildrecipe |
24 | @@ -114,8 +114,8 @@ class RecipeBuilder: |
25 | # using buildd@<hostname>. |
26 | hostname = socket.gethostname() |
27 | email = 'buildd@%s' % hostname |
28 | - lsb_release = subprocess.Popen(['sudo', |
29 | - '/usr/sbin/chroot', self.chroot_path, 'lsb_release', |
30 | + lsb_release = subprocess.Popen([ |
31 | + 'sudo', '/usr/sbin/chroot', self.chroot_path, 'lsb_release', |
32 | '-r', '-s'], stdout=subprocess.PIPE, universal_newlines=True) |
33 | distroseries_version = lsb_release.communicate()[0].rstrip() |
34 | assert lsb_release.returncode == 0 |
35 | @@ -190,12 +190,13 @@ class RecipeBuilder: |
36 | control = self.getSourceControl() |
37 | with open(os.path.join( |
38 | self.apt_dir, "%s.dsc" % package), "w") as dummy_dsc: |
39 | - print(dedent("""\ |
40 | - Format: 1.0 |
41 | - Source: %(package)s |
42 | - Architecture: any |
43 | - Version: 99:0 |
44 | - Maintainer: invalid@example.org""") % {"package": package}, |
45 | + print( |
46 | + dedent("""\ |
47 | + Format: 1.0 |
48 | + Source: %(package)s |
49 | + Architecture: any |
50 | + Version: 99:0 |
51 | + Maintainer: invalid@example.org""") % {"package": package}, |
52 | file=dummy_dsc) |
53 | for field in ( |
54 | "Build-Depends", "Build-Depends-Indep", |
55 | @@ -208,17 +209,18 @@ class RecipeBuilder: |
56 | def runAptFtparchive(self): |
57 | conf_path = os.path.join(self.apt_dir, "ftparchive.conf") |
58 | with open(conf_path, "w") as conf: |
59 | - print(dedent("""\ |
60 | - Dir::ArchiveDir "%(apt_dir)s"; |
61 | - Default::Sources::Compress ". bzip2"; |
62 | - BinDirectory "%(apt_dir)s" { Sources "Sources"; }; |
63 | - APT::FTPArchive::Release { |
64 | - Origin "buildrecipe-archive"; |
65 | - Label "buildrecipe-archive"; |
66 | - Suite "invalid"; |
67 | - Codename "invalid"; |
68 | - Description "buildrecipe temporary archive"; |
69 | - };""") % {"apt_dir": self.apt_dir}, |
70 | + print( |
71 | + dedent("""\ |
72 | + Dir::ArchiveDir "%(apt_dir)s"; |
73 | + Default::Sources::Compress ". bzip2"; |
74 | + BinDirectory "%(apt_dir)s" { Sources "Sources"; }; |
75 | + APT::FTPArchive::Release { |
76 | + Origin "buildrecipe-archive"; |
77 | + Label "buildrecipe-archive"; |
78 | + Suite "invalid"; |
79 | + Codename "invalid"; |
80 | + Description "buildrecipe temporary archive"; |
81 | + };""") % {"apt_dir": self.apt_dir}, |
82 | file=conf) |
83 | ftparchive_env = dict(os.environ) |
84 | ftparchive_env.pop("APT_CONFIG", None) |
85 | diff --git a/bin/test_buildd_generatetranslationtemplates b/bin/test_buildd_generatetranslationtemplates |
86 | index 85ddc2e..2282f1d 100755 |
87 | --- a/bin/test_buildd_generatetranslationtemplates |
88 | +++ b/bin/test_buildd_generatetranslationtemplates |
89 | @@ -28,8 +28,3 @@ build_type = 'translation-templates' |
90 | filemap = {} |
91 | args = {'branch_url': 'no-branch-here-sorry'} |
92 | print(proxy.build(buildid, build_type, chroot_sha1, filemap, args)) |
93 | -#status = proxy.status() |
94 | -#for filename, sha1 in status[3].iteritems(): |
95 | -# print(filename) |
96 | -#proxy.clean() |
97 | - |
98 | diff --git a/bin/test_buildd_recipe b/bin/test_buildd_recipe |
99 | index 849b28b..d4f5ed6 100755 |
100 | --- a/bin/test_buildd_recipe |
101 | +++ b/bin/test_buildd_recipe |
102 | @@ -17,12 +17,14 @@ distroseries_name = 'maverick' |
103 | recipe_text = """# bzr-builder format 0.2 deb-version {debupstream}-0~{revno} |
104 | http://bazaar.launchpad.dev/~ppa-user/+junk/wakeonlan""" |
105 | |
106 | + |
107 | def deb_line(host, suites): |
108 | prefix = 'deb http://' |
109 | - if apt_cacher_ng_host != None: |
110 | + if apt_cacher_ng_host is not None: |
111 | prefix += '%s:3142/' % apt_cacher_ng_host |
112 | return '%s%s %s %s' % (prefix, host, distroseries_name, suites) |
113 | |
114 | + |
115 | proxy = ServerProxy('http://localhost:8221/rpc') |
116 | print(proxy.echo('Hello World')) |
117 | print(proxy.info()) |
118 | @@ -44,8 +46,5 @@ print(proxy.build( |
119 | deb_line('%s.archive.ubuntu.com/ubuntu' % country_code, |
120 | 'main universe'), |
121 | deb_line('ppa.launchpad.net/launchpad/bzr-builder-dev/ubuntu', |
122 | - 'main'),]})) |
123 | -#status = proxy.status() |
124 | -#for filename, sha1 in status[3].iteritems(): |
125 | -# print(filename) |
126 | -#proxy.clean() |
127 | + 'main'), |
128 | + ]})) |
129 | diff --git a/buildd-genconfig b/buildd-genconfig |
130 | index 2615b88..8195ef7 100755 |
131 | --- a/buildd-genconfig |
132 | +++ b/buildd-genconfig |
133 | @@ -5,42 +5,47 @@ |
134 | |
135 | from __future__ import print_function |
136 | |
137 | +from optparse import OptionParser |
138 | import os |
139 | |
140 | archtag = os.popen("dpkg --print-architecture").read().strip() |
141 | |
142 | -from optparse import OptionParser |
143 | - |
144 | parser = OptionParser() |
145 | -parser.add_option("-n", "--name", dest="NAME", |
146 | - help="the name for this buildd", |
147 | - metavar="NAME", |
148 | - default="default") |
149 | - |
150 | -parser.add_option("-H", "--host", dest="BINDHOST", |
151 | - help="the IP/host this buildd binds to", |
152 | - metavar="HOSTNAME", |
153 | - default="localhost") |
154 | - |
155 | -parser.add_option("-p", "--port", dest="BINDPORT", |
156 | - help="the port this buildd binds to", |
157 | - metavar="PORT", |
158 | - default="8221") |
159 | - |
160 | -parser.add_option("-a", "--arch", dest="ARCHTAG", |
161 | - help="the arch tag this buildd claims", |
162 | - metavar="ARCHTAG", |
163 | - default=archtag) |
164 | - |
165 | -parser.add_option("-t", "--template", dest="TEMPLATE", |
166 | - help="the template file to use", |
167 | - metavar="FILE", |
168 | - default="/usr/share/launchpad-buildd/template-buildd-slave.conf") |
169 | - |
170 | -parser.add_option("--proxy-port", dest="PROXYPORT", |
171 | - help="the port the local builder proxy binds to", |
172 | - metavar="PORT", |
173 | - default="8222") |
174 | +parser.add_option( |
175 | + "-n", "--name", dest="NAME", |
176 | + help="the name for this buildd", |
177 | + metavar="NAME", |
178 | + default="default") |
179 | + |
180 | +parser.add_option( |
181 | + "-H", "--host", dest="BINDHOST", |
182 | + help="the IP/host this buildd binds to", |
183 | + metavar="HOSTNAME", |
184 | + default="localhost") |
185 | + |
186 | +parser.add_option( |
187 | + "-p", "--port", dest="BINDPORT", |
188 | + help="the port this buildd binds to", |
189 | + metavar="PORT", |
190 | + default="8221") |
191 | + |
192 | +parser.add_option( |
193 | + "-a", "--arch", dest="ARCHTAG", |
194 | + help="the arch tag this buildd claims", |
195 | + metavar="ARCHTAG", |
196 | + default=archtag) |
197 | + |
198 | +parser.add_option( |
199 | + "-t", "--template", dest="TEMPLATE", |
200 | + help="the template file to use", |
201 | + metavar="FILE", |
202 | + default="/usr/share/launchpad-buildd/template-buildd-slave.conf") |
203 | + |
204 | +parser.add_option( |
205 | + "--proxy-port", dest="PROXYPORT", |
206 | + help="the port the local builder proxy binds to", |
207 | + metavar="PORT", |
208 | + default="8222") |
209 | |
210 | (options, args) = parser.parse_args() |
211 | |
212 | diff --git a/debian/changelog b/debian/changelog |
213 | index 92cb241..a10074a 100644 |
214 | --- a/debian/changelog |
215 | +++ b/debian/changelog |
216 | @@ -1,3 +1,9 @@ |
217 | +launchpad-buildd (206) UNRELEASED; urgency=medium |
218 | + |
219 | + * Fix flake8 violations. |
220 | + |
221 | + -- Colin Watson <cjwatson@ubuntu.com> Wed, 08 Dec 2021 15:42:26 +0000 |
222 | + |
223 | launchpad-buildd (205) bionic; urgency=medium |
224 | |
225 | * Ignore NotAutomatic flag for -proposed and -backports (LP: #1016776). |
226 | diff --git a/debian/upgrade-config b/debian/upgrade-config |
227 | index 3145a89..db10239 100755 |
228 | --- a/debian/upgrade-config |
229 | +++ b/debian/upgrade-config |
230 | @@ -31,6 +31,9 @@ apt_pkg.init() |
231 | |
232 | (old_version, conf_file) = sys.argv[1:] |
233 | |
234 | +bin_path = "/usr/share/launchpad-buildd/slavebin" |
235 | + |
236 | + |
237 | def upgrade_to_12(): |
238 | print("Upgrading %s to version 12" % conf_file) |
239 | subprocess.call(["mv", conf_file, conf_file+"-prev12~"]) |
240 | @@ -38,13 +41,14 @@ def upgrade_to_12(): |
241 | out_file = open(conf_file, "w") |
242 | for line in in_file: |
243 | if line.startswith("[debianmanager]"): |
244 | - line += "ogrepath = /usr/share/launchpad-buildd/slavebin/apply-ogre-model\n" |
245 | + line += "ogrepath = %s/apply-ogre-model\n" % bin_path |
246 | if line.startswith("sbuildargs"): |
247 | line = line.replace("-A", "") |
248 | out_file.write(line) |
249 | in_file.close() |
250 | out_file.close() |
251 | |
252 | + |
253 | def upgrade_to_34(): |
254 | print("Upgrading %s to version 34" % conf_file) |
255 | subprocess.call(["mv", conf_file, conf_file+"-prev34~"]) |
256 | @@ -52,11 +56,12 @@ def upgrade_to_34(): |
257 | out_file = open(conf_file, "w") |
258 | for line in in_file: |
259 | if line.startswith("[debianmanager]"): |
260 | - line += "sourcespath = /usr/share/launchpad-buildd/slavebin/override-sources-list\n" |
261 | + line += "sourcespath = %s/override-sources-list\n" % bin_path |
262 | out_file.write(line) |
263 | in_file.close() |
264 | out_file.close() |
265 | |
266 | + |
267 | def upgrade_to_39(): |
268 | print("Upgrading %s to version 39" % conf_file) |
269 | subprocess.call(["mv", conf_file, conf_file+"-prev39~"]) |
270 | @@ -64,13 +69,14 @@ def upgrade_to_39(): |
271 | out_file = open(conf_file, "w") |
272 | for line in in_file: |
273 | if line.startswith("sbuildargs"): |
274 | - line = line.replace("-dautobuild ","") |
275 | + line = line.replace("-dautobuild ", "") |
276 | if line.startswith("[slave]"): |
277 | line += "ntphost = ntp.buildd\n" |
278 | out_file.write(line) |
279 | in_file.close() |
280 | out_file.close() |
281 | |
282 | + |
283 | def upgrade_to_57(): |
284 | print("Upgrading %s to version 57" % conf_file) |
285 | subprocess.call(["mv", conf_file, conf_file+"-prev57~"]) |
286 | @@ -90,6 +96,7 @@ def upgrade_to_57(): |
287 | in_file.close() |
288 | out_file.close() |
289 | |
290 | + |
291 | def upgrade_to_58(): |
292 | print("Upgrading %s to version 58" % conf_file) |
293 | subprocess.call(["mv", conf_file, conf_file+"-prev58~"]) |
294 | @@ -98,8 +105,8 @@ def upgrade_to_58(): |
295 | out_file.write(in_file.read()) |
296 | out_file.write( |
297 | '\n[sourcepackagerecipemanager]\n' |
298 | - 'buildrecipepath = /usr/share/launchpad-buildd' |
299 | - '/slavebin/buildrecipe\n') |
300 | + 'buildrecipepath = %s/buildrecipe\n' % bin_path) |
301 | + |
302 | |
303 | def upgrade_to_59(): |
304 | print("Upgrading %s to version 59" % conf_file) |
305 | @@ -109,8 +116,9 @@ def upgrade_to_59(): |
306 | out_file.write(in_file.read()) |
307 | out_file.write( |
308 | '\n[translationtemplatesmanager]\n' |
309 | - 'generatepath = /usr/share/launchpad-buildd/slavebin/generate-translation-templates\n' |
310 | - 'resultarchive = translation-templates.tar.gz\n') |
311 | + 'generatepath = %s/generate-translation-templates\n' |
312 | + 'resultarchive = translation-templates.tar.gz\n' % bin_path) |
313 | + |
314 | |
315 | def upgrade_to_63(): |
316 | print("Upgrading %s to version 63" % conf_file) |
317 | @@ -121,6 +129,7 @@ def upgrade_to_63(): |
318 | if not line.startswith('ogrepath'): |
319 | out_file.write(line) |
320 | |
321 | + |
322 | def upgrade_to_110(): |
323 | print("Upgrading %s to version 110" % conf_file) |
324 | subprocess.call(["mv", conf_file, conf_file+"-prev110~"]) |
325 | @@ -128,11 +137,12 @@ def upgrade_to_110(): |
326 | out_file = open(conf_file, "w") |
327 | for line in in_file: |
328 | if line.startswith("[allmanagers]"): |
329 | - line += "preppath = /usr/share/launchpad-buildd/slavebin/slave-prep\n" |
330 | + line += "preppath = %s/slave-prep\n" % bin_path |
331 | out_file.write(line) |
332 | in_file.close() |
333 | out_file.close() |
334 | |
335 | + |
336 | def upgrade_to_115(): |
337 | print("Upgrading %s to version 115" % conf_file) |
338 | subprocess.call(["mv", conf_file, conf_file+"-prev115~"]) |
339 | @@ -143,13 +153,15 @@ def upgrade_to_115(): |
340 | if line.startswith("[allmanagers]"): |
341 | in_allmanagers = True |
342 | elif in_allmanagers and (line.startswith("[") or not line.strip()): |
343 | - out_file.write("processscanpath = /usr/share/launchpad-buildd/slavebin/scan-for-processes\n") |
344 | + out_file.write( |
345 | + "processscanpath = %s/scan-for-processes\n" % bin_path) |
346 | in_allmanagers = False |
347 | if not line.startswith("processscanpath = "): |
348 | out_file.write(line) |
349 | in_file.close() |
350 | out_file.close() |
351 | |
352 | + |
353 | def upgrade_to_120(): |
354 | print("Upgrading %s to version 120" % conf_file) |
355 | subprocess.call(["mv", conf_file, conf_file+"-prev120~"]) |
356 | @@ -158,10 +170,11 @@ def upgrade_to_120(): |
357 | out_file.write(in_file.read()) |
358 | out_file.write( |
359 | "\n[livefilesystemmanager]\n" |
360 | - "buildlivefspath = /usr/share/launchpad-buildd/slavebin/buildlivefs\n") |
361 | + "buildlivefspath = %s/buildlivefs\n" % bin_path) |
362 | in_file.close() |
363 | out_file.close() |
364 | |
365 | + |
366 | def upgrade_to_126(): |
367 | print("Upgrading %s to version 126" % conf_file) |
368 | subprocess.call(["mv", conf_file, conf_file+"-prev126~"]) |
369 | @@ -176,6 +189,7 @@ def upgrade_to_126(): |
370 | in_file.close() |
371 | out_file.close() |
372 | |
373 | + |
374 | def upgrade_to_127(): |
375 | print("Upgrading %s to version 127" % conf_file) |
376 | os.rename(conf_file, conf_file + "-prev127~") |
377 | @@ -209,6 +223,7 @@ def upgrade_to_127(): |
378 | in_file.close() |
379 | out_file.close() |
380 | |
381 | + |
382 | def upgrade_to_162(): |
383 | print("Upgrading %s to version 162" % conf_file) |
384 | os.rename(conf_file, conf_file + "-prev162~") |
385 | @@ -220,6 +235,7 @@ def upgrade_to_162(): |
386 | "\n[snapmanager]\n" |
387 | "proxyport = 8222\n") |
388 | |
389 | + |
390 | def upgrade_to_190(): |
391 | print("Upgrading %s to version 190" % conf_file) |
392 | os.rename(conf_file, conf_file + "-prev190~") |
393 | @@ -231,6 +247,7 @@ def upgrade_to_190(): |
394 | line = "[builder]\n" |
395 | out_file.write(line) |
396 | |
397 | + |
398 | def upgrade_to_200(): |
399 | print("Upgrading %s to version 200" % conf_file) |
400 | |
401 | @@ -273,6 +290,7 @@ def upgrade_to_200(): |
402 | (line.startswith("[") or not line.strip())): |
403 | in_snapmanager = False |
404 | |
405 | + |
406 | if __name__ == "__main__": |
407 | old_version = re.sub(r'[~-].*', '', old_version) |
408 | if apt_pkg.version_compare(old_version, "12") < 0: |
409 | diff --git a/lpbuildd/binarypackage.py b/lpbuildd/binarypackage.py |
410 | index 7312473..1bbf831 100644 |
411 | --- a/lpbuildd/binarypackage.py |
412 | +++ b/lpbuildd/binarypackage.py |
413 | @@ -48,7 +48,11 @@ APT_DUBIOUS_DEP_PATTERNS = [ |
414 | |
415 | |
416 | class BuildLogRegexes: |
417 | - """Build log regexes for performing actions based on regexes, and extracting dependencies for auto dep-waits""" |
418 | + """Various build log regexes. |
419 | + |
420 | + These allow performing actions based on regexes, and extracting |
421 | + dependencies for auto dep-waits. |
422 | + """ |
423 | GIVENBACK = [ |
424 | (r"^E: There are problems and -y was used without --force-yes"), |
425 | ] |
426 | @@ -131,15 +135,16 @@ class BinaryPackageBuildManager(DebianBuildManager): |
427 | # Use the "plain" chroot type because we do the necessary setup |
428 | # and teardown ourselves: it's easier to do this the same way |
429 | # for all build types. |
430 | - print(dedent('''\ |
431 | - [build-{buildid}] |
432 | - description=build-{buildid} |
433 | - groups=sbuild,root |
434 | - root-groups=sbuild,root |
435 | - type=plain |
436 | - directory={chroot_path} |
437 | - ''').format( |
438 | - buildid=self._buildid, chroot_path=self.chroot_path), |
439 | + print( |
440 | + dedent('''\ |
441 | + [build-{buildid}] |
442 | + description=build-{buildid} |
443 | + groups=sbuild,root |
444 | + root-groups=sbuild,root |
445 | + type=plain |
446 | + directory={chroot_path} |
447 | + ''').format( |
448 | + buildid=self._buildid, chroot_path=self.chroot_path), |
449 | file=schroot_file, end='') |
450 | schroot_file.flush() |
451 | subprocess.check_call( |
452 | @@ -285,9 +290,8 @@ class BinaryPackageBuildManager(DebianBuildManager): |
453 | return True |
454 | dep_restrictions = dep.get("restrictions") |
455 | if dep_restrictions is not None: |
456 | - if all( |
457 | - any(restriction.enabled for restriction in restrlist) |
458 | - for restrlist in dep_restrictions): |
459 | + if all(any(restriction.enabled for restriction in restrlist) |
460 | + for restrlist in dep_restrictions): |
461 | # This dependency "matches" in the sense that it's ignored |
462 | # when no build profiles are enabled. |
463 | return True |
464 | diff --git a/lpbuildd/builder.py b/lpbuildd/builder.py |
465 | index b8362d3..ad08639 100644 |
466 | --- a/lpbuildd/builder.py |
467 | +++ b/lpbuildd/builder.py |
468 | @@ -193,7 +193,8 @@ class BuildManager(object): |
469 | if notify: |
470 | iterate = partial(self.iterateReap, state) |
471 | else: |
472 | - iterate = lambda success: None |
473 | + def iterate(success): |
474 | + pass |
475 | self.runTargetSubProcess("scan-for-processes", iterate=iterate) |
476 | |
477 | def doCleanup(self): |
478 | @@ -232,9 +233,8 @@ class BuildManager(object): |
479 | |
480 | os.mkdir("%s/build-%s" % (self.home, self._buildid)) |
481 | for f in files: |
482 | - os.symlink( self._builder.cachePath(files[f]), |
483 | - "%s/build-%s/%s" % (self.home, |
484 | - self._buildid, f)) |
485 | + os.symlink(self._builder.cachePath(files[f]), |
486 | + "%s/build-%s/%s" % (self.home, self._buildid, f)) |
487 | self._chroottarfile = self._builder.cachePath(chroot) |
488 | |
489 | self.image_type = extra_args.get('image_type', 'chroot') |
490 | diff --git a/lpbuildd/check_implicit_pointer_functions.py b/lpbuildd/check_implicit_pointer_functions.py |
491 | index 7f28338..78df89f 100755 |
492 | --- a/lpbuildd/check_implicit_pointer_functions.py |
493 | +++ b/lpbuildd/check_implicit_pointer_functions.py |
494 | @@ -42,12 +42,12 @@ implicit_pattern = re.compile( |
495 | pointer_pattern = re.compile( |
496 | br"([^:]*):(\d+):(\d+:)? warning: " |
497 | br"(" |
498 | - br"(assignment" |
499 | - br"|initialization" |
500 | - br"|return" |
501 | - br"|passing arg \d+ of `[^']*'" |
502 | - br"|passing arg \d+ of pointer to function" |
503 | - br") makes pointer from integer without a cast" |
504 | + br"(assignment" |
505 | + br"|initialization" |
506 | + br"|return" |
507 | + br"|passing arg \d+ of `[^']*'" |
508 | + br"|passing arg \d+ of pointer to function" |
509 | + br") makes pointer from integer without a cast" |
510 | br"|" |
511 | br"cast to pointer from integer of different size)") |
512 | |
513 | @@ -77,7 +77,7 @@ def filter_log(in_file, out_file, in_line=False): |
514 | pointer_filename = m.group(1) |
515 | pointer_linenum = int(m.group(2)) |
516 | if (last_implicit_filename == pointer_filename |
517 | - and last_implicit_linenum == pointer_linenum): |
518 | + and last_implicit_linenum == pointer_linenum): |
519 | err = ( |
520 | b"Function `%s' implicitly converted to pointer at " |
521 | b"%s:%d" % ( |
522 | diff --git a/lpbuildd/oci.py b/lpbuildd/oci.py |
523 | index aa28a03..c6e103c 100644 |
524 | --- a/lpbuildd/oci.py |
525 | +++ b/lpbuildd/oci.py |
526 | @@ -242,7 +242,6 @@ class OCIBuildManager(BuildManagerProxyMixin, DebianBuildManager): |
527 | source_name, target_name)) |
528 | shutil.copy(source_name, target_name) |
529 | |
530 | - |
531 | # We need these mapping files |
532 | sha_directory = tempfile.mkdtemp() |
533 | # This can change depending on the kernel options / docker package |
534 | @@ -255,7 +254,7 @@ class OCIBuildManager(BuildManagerProxyMixin, DebianBuildManager): |
535 | # we will have no contents from it. |
536 | if self.backend.path_exists(sha_path): |
537 | sha_files = [x for x in self.backend.listdir(sha_path) |
538 | - if not x.startswith('.')] |
539 | + if not x.startswith('.')] |
540 | for file in sha_files: |
541 | self.backend.copy_out( |
542 | os.path.join(sha_path, file), |
543 | diff --git a/lpbuildd/proxy.py b/lpbuildd/proxy.py |
544 | index 908770d..de6e3c7 100644 |
545 | --- a/lpbuildd/proxy.py |
546 | +++ b/lpbuildd/proxy.py |
547 | @@ -128,15 +128,15 @@ class BuilderProxyRequest(http.Request): |
548 | if self.startedWriting: |
549 | return |
550 | self.startedWriting = 1 |
551 | - l = [] |
552 | - l.append( |
553 | + lines = [] |
554 | + lines.append( |
555 | self.clientproto + b" " + intToBytes(self.code) + b" " + |
556 | self.code_message + b"\r\n") |
557 | for name, values in self.responseHeaders.getAllRawHeaders(): |
558 | for value in values: |
559 | - l.extend([name, b": ", value, b"\r\n"]) |
560 | - l.append(b"\r\n") |
561 | - self.transport.writeSequence(l) |
562 | + lines.extend([name, b": ", value, b"\r\n"]) |
563 | + lines.append(b"\r\n") |
564 | + self.transport.writeSequence(lines) |
565 | |
566 | def write(self, data): |
567 | if self.channel is not None: |
568 | diff --git a/lpbuildd/sourcepackagerecipe.py b/lpbuildd/sourcepackagerecipe.py |
569 | index b2f46cb..4e237a6 100644 |
570 | --- a/lpbuildd/sourcepackagerecipe.py |
571 | +++ b/lpbuildd/sourcepackagerecipe.py |
572 | @@ -117,9 +117,8 @@ class SourcePackageRecipeBuildManager(DebianBuildManager): |
573 | print("Returning build status: Build failed") |
574 | self._builder.buildFail() |
575 | self.alreadyfailed = True |
576 | - elif ( |
577 | - retcode >= RETCODE_FAILURE_INSTALL and |
578 | - retcode <= RETCODE_FAILURE_BUILD_SOURCE_PACKAGE): |
579 | + elif (retcode >= RETCODE_FAILURE_INSTALL and |
580 | + retcode <= RETCODE_FAILURE_BUILD_SOURCE_PACKAGE): |
581 | # XXX AaronBentley 2009-01-13: We should handle depwait separately |
582 | if not self.alreadyfailed: |
583 | self._builder.buildFail() |
584 | diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py |
585 | index d5ade71..5d0b3ab 100644 |
586 | --- a/lpbuildd/target/build_charm.py |
587 | +++ b/lpbuildd/target/build_charm.py |
588 | @@ -136,4 +136,3 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin, |
589 | logger.exception('Build failed') |
590 | return RETCODE_FAILURE_BUILD |
591 | return 0 |
592 | - |
593 | diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py |
594 | index 6ddd1d0..163176d 100644 |
595 | --- a/lpbuildd/target/lxd.py |
596 | +++ b/lpbuildd/target/lxd.py |
597 | @@ -402,8 +402,8 @@ class LXD(Backend): |
598 | if os.path.islink(resolv_conf): |
599 | resolv_conf = os.path.realpath(resolv_conf) |
600 | if (resolv_conf == "/run/systemd/resolve/stub-resolv.conf" and |
601 | - os.path.isfile("/run/systemd/resolve/resolv.conf")): |
602 | - resolv_conf = "/run/systemd/resolve/resolv.conf" |
603 | + os.path.isfile("/run/systemd/resolve/resolv.conf")): |
604 | + resolv_conf = "/run/systemd/resolve/resolv.conf" |
605 | |
606 | self.copy_in(resolv_conf, "/etc/resolv.conf") |
607 | |
608 | diff --git a/lpbuildd/target/operation.py b/lpbuildd/target/operation.py |
609 | index 7020786..2f9fe64 100644 |
610 | --- a/lpbuildd/target/operation.py |
611 | +++ b/lpbuildd/target/operation.py |
612 | @@ -5,8 +5,6 @@ from __future__ import print_function |
613 | |
614 | __metaclass__ = type |
615 | |
616 | -import os |
617 | - |
618 | from lpbuildd.target.backend import make_backend |
619 | |
620 | |
621 | diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py |
622 | index 38d3337..35be3bb 100644 |
623 | --- a/lpbuildd/target/tests/test_lxd.py |
624 | +++ b/lpbuildd/target/tests/test_lxd.py |
625 | @@ -312,8 +312,9 @@ class TestLXD(TestCase): |
626 | ("lxc.network.0.ipv4.gateway", "10.10.10.1"), |
627 | ]) |
628 | |
629 | - raw_lxc_config = "".join("{key}={val}\n".format(key=key, val=val) |
630 | - for key, val in sorted(raw_lxc_config + extra_raw_lxc_config)) |
631 | + raw_lxc_config = "".join( |
632 | + "{key}={val}\n".format(key=key, val=val) |
633 | + for key, val in sorted(raw_lxc_config + extra_raw_lxc_config)) |
634 | |
635 | expected_config = { |
636 | "security.privileged": "true", |
637 | diff --git a/lpbuildd/target/vcs.py b/lpbuildd/target/vcs.py |
638 | index 4ddd9e5..f02e540 100644 |
639 | --- a/lpbuildd/target/vcs.py |
640 | +++ b/lpbuildd/target/vcs.py |
641 | @@ -57,7 +57,8 @@ class VCSOperationMixin: |
642 | else: |
643 | return ["git"] |
644 | |
645 | - def vcs_fetch(self, name, cwd, env=None, quiet=False, git_shallow_clone=False): |
646 | + def vcs_fetch(self, name, cwd, env=None, quiet=False, |
647 | + git_shallow_clone=False): |
648 | full_env = OrderedDict() |
649 | full_env["LANG"] = "C.UTF-8" |
650 | full_env["SHELL"] = "/bin/sh" |
651 | diff --git a/lpbuildd/tests/fakebuilder.py b/lpbuildd/tests/fakebuilder.py |
652 | index 7731ea2..ef20810 100644 |
653 | --- a/lpbuildd/tests/fakebuilder.py |
654 | +++ b/lpbuildd/tests/fakebuilder.py |
655 | @@ -108,10 +108,10 @@ class FakeBuilder: |
656 | self._config = FakeConfig() |
657 | self.waitingfiles = {} |
658 | for fake_method in ( |
659 | - "emptyLog", "log", |
660 | - "chrootFail", "buildFail", "builderFail", "depFail", "buildOK", |
661 | - "buildComplete", |
662 | - ): |
663 | + "emptyLog", "log", |
664 | + "chrootFail", "buildFail", "builderFail", "depFail", "buildOK", |
665 | + "buildComplete", |
666 | + ): |
667 | setattr(self, fake_method, FakeMethod()) |
668 | |
669 | def cachePath(self, file): |
670 | diff --git a/lpbuildd/tests/oci_tarball.py b/lpbuildd/tests/oci_tarball.py |
671 | index 21ec013..35860ad 100644 |
672 | --- a/lpbuildd/tests/oci_tarball.py |
673 | +++ b/lpbuildd/tests/oci_tarball.py |
674 | @@ -17,8 +17,9 @@ class OCITarball: |
675 | @property |
676 | def config(self): |
677 | return self._makeFile( |
678 | - {"rootfs": {"diff_ids": |
679 | - ["sha256:diff1", "sha256:diff2", "sha256:diff3"]}}, |
680 | + {"rootfs": { |
681 | + "diff_ids": [ |
682 | + "sha256:diff1", "sha256:diff2", "sha256:diff3"]}}, |
683 | 'config.json') |
684 | |
685 | @property |
686 | @@ -57,10 +58,7 @@ class OCITarball: |
687 | source = os.path.join(source_layer_directory, "layer.tar") |
688 | |
689 | os.mkdir(target_layer_directory) |
690 | - os.symlink( |
691 | - os.path.relpath(source, target_layer_directory), |
692 | - os.path.join(target_layer_directory, "layer.tar") |
693 | - ) |
694 | + os.symlink(os.path.relpath(source, target_layer_directory), target) |
695 | return target_layer_directory |
696 | |
697 | def build_tar_file(self): |
698 | diff --git a/lpbuildd/tests/test_binarypackage.py b/lpbuildd/tests/test_binarypackage.py |
699 | index c88bdb2..22c4b0a 100644 |
700 | --- a/lpbuildd/tests/test_binarypackage.py |
701 | +++ b/lpbuildd/tests/test_binarypackage.py |
702 | @@ -134,11 +134,11 @@ class TestBinaryPackageBuildManagerIteration(TestCase): |
703 | self.assertState( |
704 | BinaryPackageBuildState.SBUILD, |
705 | [ |
706 | - 'sharepath/bin/sbuild-package', 'sbuild-package', |
707 | - self.buildid, 'i386', 'warty', |
708 | - '-c', 'chroot:build-' + self.buildid, |
709 | - '--arch=i386', '--dist=warty', '--nolog', |
710 | - 'foo_1.dsc', |
711 | + 'sharepath/bin/sbuild-package', 'sbuild-package', |
712 | + self.buildid, 'i386', 'warty', |
713 | + '-c', 'chroot:build-' + self.buildid, |
714 | + '--arch=i386', '--dist=warty', '--nolog', |
715 | + 'foo_1.dsc', |
716 | ], final=True) |
717 | self.assertFalse(self.builder.wasCalled('chrootFail')) |
718 | |
719 | @@ -490,12 +490,12 @@ class TestBinaryPackageBuildManagerIteration(TestCase): |
720 | def test_relationMatches_versioned(self): |
721 | # relationMatches handles versioned dependencies correctly. |
722 | for version, expected in ( |
723 | - (("<<", "1"), False), (("<<", "1.1"), True), |
724 | - (("<=", "0.9"), False), (("<=", "1"), True), |
725 | - (("=", "1"), True), (("=", "2"), False), |
726 | - ((">=", "1"), True), ((">=", "1.1"), False), |
727 | - ((">>", "0.9"), True), ((">>", "1"), False), |
728 | - ): |
729 | + (("<<", "1"), False), (("<<", "1.1"), True), |
730 | + (("<=", "0.9"), False), (("<=", "1"), True), |
731 | + (("=", "1"), True), (("=", "2"), False), |
732 | + ((">=", "1"), True), ((">=", "1.1"), False), |
733 | + ((">>", "0.9"), True), ((">>", "1"), False), |
734 | + ): |
735 | assert_method = self.assertTrue if expected else self.assertFalse |
736 | assert_method(self.buildmanager.relationMatches( |
737 | {"name": "foo", "version": version}, {"foo": set(["1"])}), |
738 | @@ -505,10 +505,10 @@ class TestBinaryPackageBuildManagerIteration(TestCase): |
739 | # If multiple versions of a package are present, relationMatches |
740 | # returns True for dependencies that match any of them. |
741 | for version, expected in ( |
742 | - (("=", "1"), True), |
743 | - (("=", "1.1"), True), |
744 | - (("=", "2"), False), |
745 | - ): |
746 | + (("=", "1"), True), |
747 | + (("=", "1.1"), True), |
748 | + (("=", "2"), False), |
749 | + ): |
750 | assert_method = self.assertTrue if expected else self.assertFalse |
751 | assert_method(self.buildmanager.relationMatches( |
752 | {"name": "foo", "version": version}, |
753 | diff --git a/lpbuildd/tests/test_buildrecipe.py b/lpbuildd/tests/test_buildrecipe.py |
754 | index 2faa985..de7b50a 100644 |
755 | --- a/lpbuildd/tests/test_buildrecipe.py |
756 | +++ b/lpbuildd/tests/test_buildrecipe.py |
757 | @@ -277,12 +277,13 @@ class TestRecipeBuilder(TestCase): |
758 | os.makedirs(os.path.dirname(control_path)) |
759 | os.makedirs(self.builder.apt_dir) |
760 | with open(control_path, "w") as control: |
761 | - print(dedent("""\ |
762 | - Source: foo |
763 | - Build-Depends: debhelper (>= 9~), libfoo-dev |
764 | + print( |
765 | + dedent("""\ |
766 | + Source: foo |
767 | + Build-Depends: debhelper (>= 9~), libfoo-dev |
768 | |
769 | - Package: foo |
770 | - Depends: ${shlibs:Depends}"""), |
771 | + Package: foo |
772 | + Depends: ${shlibs:Depends}"""), |
773 | file=control) |
774 | self.builder.makeDummyDsc("foo") |
775 | with open(os.path.join(self.builder.apt_dir, "foo.dsc")) as dsc: |
776 | @@ -308,15 +309,16 @@ class TestRecipeBuilder(TestCase): |
777 | os.makedirs(os.path.dirname(control_path)) |
778 | os.makedirs(self.builder.apt_dir) |
779 | with open(control_path, "w") as control: |
780 | - print(dedent("""\ |
781 | - Source: foo |
782 | - Build-Depends: debhelper (>= 9~), |
783 | - libfoo-dev, |
784 | - # comment line |
785 | - pkg-config |
786 | + print( |
787 | + dedent("""\ |
788 | + Source: foo |
789 | + Build-Depends: debhelper (>= 9~), |
790 | + libfoo-dev, |
791 | + # comment line |
792 | + pkg-config |
793 | |
794 | - Package: foo |
795 | - Depends: ${shlibs:Depends}"""), |
796 | + Package: foo |
797 | + Depends: ${shlibs:Depends}"""), |
798 | file=control) |
799 | self.builder.makeDummyDsc("foo") |
800 | with open(os.path.join(self.builder.apt_dir, "foo.dsc")) as dsc: |
801 | @@ -337,13 +339,14 @@ class TestRecipeBuilder(TestCase): |
802 | def test_runAptFtparchive(self): |
803 | os.makedirs(self.builder.apt_dir) |
804 | with open(os.path.join(self.builder.apt_dir, "foo.dsc"), "w") as dsc: |
805 | - print(dedent("""\ |
806 | - Format: 1.0 |
807 | - Source: foo |
808 | - Architecture: any |
809 | - Version: 99:0 |
810 | - Maintainer: invalid@example.org |
811 | - Build-Depends: debhelper (>= 9~), libfoo-dev"""), |
812 | + print( |
813 | + dedent("""\ |
814 | + Format: 1.0 |
815 | + Source: foo |
816 | + Architecture: any |
817 | + Version: 99:0 |
818 | + Maintainer: invalid@example.org |
819 | + Build-Depends: debhelper (>= 9~), libfoo-dev"""), |
820 | file=dsc) |
821 | self.assertEqual(0, self.builder.runAptFtparchive()) |
822 | self.assertEqual( |
823 | @@ -379,12 +382,13 @@ class TestRecipeBuilder(TestCase): |
824 | # Not a valid changelog, but only the first line matters here. |
825 | print("foo (1.0-1) bionic; urgency=medium", file=changelog) |
826 | with open(control_path, "w") as control: |
827 | - print(dedent("""\ |
828 | - Source: foo |
829 | - Build-Depends: debhelper (>= 9~), libfoo-dev |
830 | + print( |
831 | + dedent("""\ |
832 | + Source: foo |
833 | + Build-Depends: debhelper (>= 9~), libfoo-dev |
834 | |
835 | - Package: foo |
836 | - Depends: ${shlibs:Depends}"""), |
837 | + Package: foo |
838 | + Depends: ${shlibs:Depends}"""), |
839 | file=control) |
840 | self.assertEqual(0, self.builder.installBuildDeps()) |
841 | self.assertThat( |
842 | diff --git a/lpbuildd/tests/test_charm.py b/lpbuildd/tests/test_charm.py |
843 | index 18e01a1..97b4a15 100644 |
844 | --- a/lpbuildd/tests/test_charm.py |
845 | +++ b/lpbuildd/tests/test_charm.py |
846 | @@ -101,7 +101,8 @@ class TestCharmBuildManagerIteration(TestCase): |
847 | "git_path": "master", |
848 | } |
849 | expected_options = [ |
850 | - "--git-repository", "https://git.launchpad.dev/~example/+git/charm", |
851 | + "--git-repository", |
852 | + "https://git.launchpad.dev/~example/+git/charm", |
853 | "--git-path", "master", |
854 | ] |
855 | yield self.startBuild(args, expected_options) |
856 | diff --git a/lpbuildd/tests/test_harness.py b/lpbuildd/tests/test_harness.py |
857 | index 049ecd1..0ea496b 100644 |
858 | --- a/lpbuildd/tests/test_harness.py |
859 | +++ b/lpbuildd/tests/test_harness.py |
860 | @@ -5,6 +5,6 @@ __metaclass__ = type |
861 | |
862 | import doctest |
863 | |
864 | + |
865 | def test_suite(): |
866 | return doctest.DocTestSuite('lpbuildd.tests.harness') |
867 | - |
868 | diff --git a/lpbuildd/tests/test_sourcepackagerecipe.py b/lpbuildd/tests/test_sourcepackagerecipe.py |
869 | index dda21d4..7a2cb48 100644 |
870 | --- a/lpbuildd/tests/test_sourcepackagerecipe.py |
871 | +++ b/lpbuildd/tests/test_sourcepackagerecipe.py |
872 | @@ -78,7 +78,7 @@ class TestSourcePackageRecipeBuildManagerIteration(TestCase): |
873 | 'archives': [ |
874 | 'deb http://archive.ubuntu.com/ubuntu maverick main universe', |
875 | 'deb http://ppa.launchpad.net/launchpad/bzr-builder-dev/' |
876 | - 'ubuntu main', |
877 | + 'ubuntu main', |
878 | ], |
879 | } |
880 | if git: |
881 | diff --git a/lpbuildd/tests/test_util.py b/lpbuildd/tests/test_util.py |
882 | index 3eb92f9..8b04d44 100644 |
883 | --- a/lpbuildd/tests/test_util.py |
884 | +++ b/lpbuildd/tests/test_util.py |
885 | @@ -21,7 +21,8 @@ class TestShellEscape(TestCase): |
886 | self.assertEqual("' '", shell_escape(" ")) |
887 | |
888 | def test_single_quotes(self): |
889 | - self.assertEqual("'shell'\"'\"'s great'", shell_escape("shell's great")) |
890 | + self.assertEqual( |
891 | + "'shell'\"'\"'s great'", shell_escape("shell's great")) |
892 | |
893 | def test_bytes(self): |
894 | self.assertEqual( |
895 | diff --git a/setup.py b/setup.py |
896 | index 32e4498..aa05864 100755 |
897 | --- a/setup.py |
898 | +++ b/setup.py |
899 | @@ -57,7 +57,7 @@ setup( |
900 | # XXX cjwatson 2015-11-04: This does in fact require python-apt, but |
901 | # that's normally shipped as a system package and specifying it here |
902 | # causes problems for Launchpad's build system. |
903 | - #'python-apt', |
904 | + # 'python-apt', |
905 | 'python-debian>=0.1.23', |
906 | 'requests', |
907 | 'six', |
LGTM
A couple of re-formats made the code less readable imho - let's have a quick discussion at standup whether the line length limit is set in stone or whether we could just # noqa this rare occasions.