Merge ~cjwatson/launchpad:annotate-build-args into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ce76311d6107d7c3dd2d70eef4ccc11beeb3d10d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:annotate-build-args
Merge into: launchpad:master
Prerequisite: ~cjwatson/launchpad:mypy-buildmaster
Diff against target: 566 lines (+204/-29)
14 files modified
lib/lp/buildmaster/builderproxy.py (+5/-1)
lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py (+147/-1)
lib/lp/buildmaster/model/buildfarmjobbehaviour.py (+9/-8)
lib/lp/charms/model/charmrecipebuildbehaviour.py (+5/-2)
lib/lp/code/model/cibuildbehaviour.py (+4/-2)
lib/lp/code/model/recipebuilder.py (+5/-2)
lib/lp/oci/model/ocirecipebuildbehaviour.py (+4/-2)
lib/lp/snappy/model/snapbuildbehaviour.py (+4/-3)
lib/lp/soyuz/model/binarypackagebuildbehaviour.py (+4/-2)
lib/lp/soyuz/model/livefsbuildbehaviour.py (+12/-4)
lib/lp/translations/model/translationtemplatesbuildbehaviour.py (+2/-1)
requirements/launchpad.txt (+1/-0)
setup.cfg (+1/-0)
tox.ini (+1/-1)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Jürgen Gmach Approve
Review via email: mp+435140@code.launchpad.net

Commit message

Add type annotations for arguments sent to builders

Description of the change

It's difficult to do a completely accurate job of this with Python 3.5, but we can get most of the benefit (in particular, protection against simple typos and against passing the wrong type for an argument) from a single `TypedDict`. The annotation is long and complicated because the protocol has evolved in quite an ad-hoc way for many years, and a number of the arguments were difficult to describe concisely without context; still, the exercise of going through the whole thing was quite a useful one and found a few forgotten deprecations to clean up.

There should be no functional change from this commit.

Dependencies MP: https://code.launchpad.net/~cjwatson/lp-source-dependencies/+git/lp-source-dependencies/+merge/435138

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Awesome work! Thanks for much for taking the time to document the massive list of build arguments.

review: Approve
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
2index a49a251..2182194 100644
3--- a/lib/lp/buildmaster/builderproxy.py
4+++ b/lib/lp/buildmaster/builderproxy.py
5@@ -16,11 +16,13 @@ __all__ = [
6
7 import base64
8 import time
9+from typing import Dict, Generator
10
11 from twisted.internet import defer
12
13 from lp.buildmaster.downloader import RequestProxyTokenCommand
14 from lp.buildmaster.interfaces.builder import CannotBuild
15+from lp.buildmaster.interfaces.buildfarmjobbehaviour import BuildArgs
16 from lp.services.config import config
17
18
19@@ -33,7 +35,9 @@ class BuilderProxyMixin:
20 """Methods for handling builds with the Snap Build Proxy enabled."""
21
22 @defer.inlineCallbacks
23- def addProxyArgs(self, args, allow_internet=True):
24+ def addProxyArgs(
25+ self, args: BuildArgs, allow_internet: bool = True
26+ ) -> Generator[None, Dict[str, str], None]:
27 if _get_proxy_config("builder_proxy_host") and allow_internet:
28 token = yield self._requestProxyToken()
29 args[
30diff --git a/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py b/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py
31index 56bd4cf..9f847a7 100644
32--- a/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py
33+++ b/lib/lp/buildmaster/interfaces/buildfarmjobbehaviour.py
34@@ -4,11 +4,155 @@
35 """Interface for build farm job behaviours."""
36
37 __all__ = [
38+ "BuildArgs",
39 "IBuildFarmJobBehaviour",
40 ]
41
42+from typing import Any, Dict, Generator, List, Union
43+
44+from typing_extensions import TypedDict
45 from zope.interface import Attribute, Interface
46
47+# XXX cjwatson 2023-01-04: This should ultimately end up as a protocol
48+# specification maintained in launchpad-buildd as (probably) pydantic
49+# models, but this is difficult while Launchpad runs on Python < 3.7.
50+# XXX cjwatson 2023-01-04: Several of these items are only valid for certain
51+# build job types; however, TypedDict only supports inheritance if you're
52+# using the class-based syntax, which isn't available in Python 3.5. As a
53+# result, it's difficult to construct a completely accurate type declaration
54+# on Python 3.5. In the meantime, job type constraints are noted in the
55+# comments with the type name (i.e. `IBuildFarmJobBehaviour.builder_type`)
56+# in brackets.
57+BuildArgs = TypedDict(
58+ "BuildArgs",
59+ {
60+ # True if this build should build architecture-independent packages
61+ # as well as architecture-dependent packages [binarypackage].
62+ "arch_indep": bool,
63+ # The architecture tag to build for.
64+ "arch_tag": str,
65+ # Whether this is a build in a private archive. (This causes URLs
66+ # in the build log to be sanitized.)
67+ "archive_private": bool,
68+ # The name of the target archive's purpose, e.g. PRIMARY or PPA
69+ # [binarypackage; required for sourcepackagerecipe].
70+ "archive_purpose": str,
71+ # A list of sources.list lines to use for this build.
72+ "archives": List[str],
73+ # The email address of the person who requested the recipe build
74+ # [required for sourcepackagerecipe].
75+ "author_email": str,
76+ # The name of the person who requested the recipe build [required
77+ # for sourcepackagerecipe].
78+ "author_name": str,
79+ # The URL of the Bazaar branch to build from [charm, ci, oci, snap,
80+ # translation-templates].
81+ "branch": str,
82+ # The URL of the Bazaar branch to build from
83+ # [translation-templates]. Deprecated alias for branch.
84+ "branch_url": str,
85+ # ARG variables to pass when building this OCI recipe [oci].
86+ "build_args": Dict[str, str],
87+ # If True, this build should also build debug symbol packages
88+ # [binarypackage].
89+ "build_debug_symbols": bool,
90+ # The relative path to the build file within this recipe's branch
91+ # [oci].
92+ "build_file": str,
93+ # The subdirectory within this recipe's branch containing the build
94+ # file [charm, oci].
95+ "build_path": str,
96+ # The ID of the build request that prompted this build [snap].
97+ "build_request_id": int,
98+ # The RFC3339-formatted time when the build request that prompted
99+ # this build was made [snap].
100+ "build_request_timestamp": str,
101+ # If True, also build a tarball containing all source code [snap].
102+ "build_source_tarball": bool,
103+ # The URL of this build.
104+ "build_url": str,
105+ # Source snap channels to use for this build [charm, ci, snap].
106+ "channels": Dict[str, str],
107+ # The date stamp to set in the built image [livefs].
108+ "datestamp": str,
109+ # The name of the distribution to build for [no longer used, but
110+ # currently required for binarypackage].
111+ "distribution": str,
112+ # The name of the series to build for [sourcepackagerecipe].
113+ # XXX cjwatson 2017-07-26: This duplicates "series", which is common
114+ # to all build types; this name for it is deprecated and should be
115+ # removed once launchpad-buildd no longer requires it.
116+ "distroseries_name": str,
117+ # A dictionary of additional environment variables to pass to the CI
118+ # build runner [ci].
119+ "environment_variables": Dict[str, str],
120+ # If True, this build is running in an ephemeral environment; skip
121+ # final cleanup steps.
122+ "fast_cleanup": bool,
123+ # True if this build is for a Git-based source package recipe,
124+ # otherwise False [sourcepackagerecipe].
125+ "git": bool,
126+ # The Git branch path to build from [charm, ci, oci, snap,
127+ # translation-templates].
128+ "git_path": str,
129+ # The URL of the Git repository to build from [charm, ci, oci, snap,
130+ # translation-templates].
131+ "git_repository": str,
132+ # A list of stages in this build's configured pipeline [required for
133+ # ci].
134+ "jobs": List[str],
135+ # Dictionary of additional metadata to pass to the build [oci].
136+ # XXX cjwatson 2023-01-04: This doesn't appear to be used by
137+ # launchpad-buildd at the moment.
138+ "metadata": Dict[str, Any],
139+ # The name of the recipe [required for charm, oci, snap].
140+ "name": str,
141+ # The name of the component to build for [required for
142+ # binarypackage, sourcepackagerecipe]. This argument has a strange
143+ # name due to a historical in-joke: because components form a sort
144+ # of layered structure where "outer" components like universe
145+ # include "inner" components like main, the component structure was
146+ # at one point referred to as the "ogre model" (from the movie
147+ # "Shrek": "Ogres have layers. Onions have layers. You get it? We
148+ # both have layers.").
149+ "ogrecomponent": str,
150+ # A list of sources.list lines for the CI build runner to use [ci].
151+ "package_repositories": List[str],
152+ # A dictionary of plugin settings to pass to the CI build runner
153+ # [ci].
154+ "plugin_settings": Dict[str, str],
155+ # The lower-cased name of the pocket to build from [required for
156+ # livefs].
157+ "pocket": str,
158+ # If True, the source of this build is private [snap; also passed
159+ # for charm and ci but currently unused there].
160+ "private": bool,
161+ # The URL of the proxy for internet access [charm, ci, oci, snap].
162+ "proxy_url": str,
163+ # The text of the recipe to build [required for
164+ # sourcepackagerecipe].
165+ "recipe_text": str,
166+ # The URL for revoking proxy authorization tokens [charm, ci, oci,
167+ # snap].
168+ "revocation_endpoint": str,
169+ # If True, scan job output for malware [ci].
170+ "scan_malware": bool,
171+ # A dictionary of secrets to pass to the CI build runner [ci].
172+ "secrets": Dict[str, str],
173+ # The name of the series to build for [required for all types].
174+ "series": str,
175+ # The name of the suite to build for [required for binarypackage,
176+ # sourcepackagerecipe].
177+ "suite": str,
178+ # A list of target architecture tags to build for [snap].
179+ "target_architectures": List[str],
180+ # A list of base64-encoded public keys for apt archives used by this
181+ # build.
182+ "trusted_keys": List[str],
183+ },
184+ total=False,
185+)
186+
187
188 class IBuildFarmJobBehaviour(Interface):
189
190@@ -53,7 +197,9 @@ class IBuildFarmJobBehaviour(Interface):
191 fault.
192 """
193
194- def extraBuildArgs(logger=None):
195+ def extraBuildArgs(
196+ logger=None,
197+ ) -> Union[BuildArgs, Generator[Any, Any, BuildArgs]]:
198 """Return extra arguments required by the builder for this build.
199
200 :param logger: An optional logger.
201diff --git a/lib/lp/buildmaster/model/buildfarmjobbehaviour.py b/lib/lp/buildmaster/model/buildfarmjobbehaviour.py
202index 25f4678..e2bc1d8 100644
203--- a/lib/lp/buildmaster/model/buildfarmjobbehaviour.py
204+++ b/lib/lp/buildmaster/model/buildfarmjobbehaviour.py
205@@ -25,6 +25,7 @@ from lp.buildmaster.enums import (
206 BuildStatus,
207 )
208 from lp.buildmaster.interfaces.builder import BuildDaemonError, CannotBuild
209+from lp.buildmaster.interfaces.buildfarmjobbehaviour import BuildArgs
210 from lp.registry.interfaces.pocket import PackagePublishingPocket
211 from lp.services.config import config
212 from lp.services.helpers import filenameToContentType
213@@ -93,15 +94,15 @@ class BuildFarmJobBehaviourBase:
214 "This build type does not support accessing private resources."
215 )
216
217- def extraBuildArgs(self, logger=None):
218+ def extraBuildArgs(self, logger=None) -> BuildArgs:
219 """The default behaviour is to send only common extra arguments."""
220- args = {}
221- args["arch_tag"] = self.distro_arch_series.architecturetag
222- args["archive_private"] = self.archive.private
223- args["build_url"] = canonical_url(self.build)
224- args["fast_cleanup"] = self._builder.virtualized
225- args["series"] = self.distro_arch_series.distroseries.name
226- return args
227+ return {
228+ "arch_tag": self.distro_arch_series.architecturetag,
229+ "archive_private": self.archive.private,
230+ "build_url": canonical_url(self.build),
231+ "fast_cleanup": self._builder.virtualized,
232+ "series": self.distro_arch_series.distroseries.name,
233+ }
234
235 @defer.inlineCallbacks
236 def composeBuildRequest(self, logger):
237diff --git a/lib/lp/charms/model/charmrecipebuildbehaviour.py b/lib/lp/charms/model/charmrecipebuildbehaviour.py
238index fffe7cf..9e95250 100644
239--- a/lib/lp/charms/model/charmrecipebuildbehaviour.py
240+++ b/lib/lp/charms/model/charmrecipebuildbehaviour.py
241@@ -10,6 +10,8 @@ __all__ = [
242 "CharmRecipeBuildBehaviour",
243 ]
244
245+from typing import Any, Generator
246+
247 from twisted.internet import defer
248 from zope.component import adapter
249 from zope.interface import implementer
250@@ -19,6 +21,7 @@ from lp.buildmaster.builderproxy import BuilderProxyMixin
251 from lp.buildmaster.enums import BuildBaseImageType
252 from lp.buildmaster.interfaces.builder import CannotBuild
253 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
254+ BuildArgs,
255 IBuildFarmJobBehaviour,
256 )
257 from lp.buildmaster.model.buildfarmjobbehaviour import (
258@@ -70,12 +73,12 @@ class CharmRecipeBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
259 )
260
261 @defer.inlineCallbacks
262- def extraBuildArgs(self, logger=None):
263+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
264 """
265 Return the extra arguments required by the worker for the given build.
266 """
267 build = self.build
268- args = yield super().extraBuildArgs(logger=logger)
269+ args = yield super().extraBuildArgs(logger=logger) # type: BuildArgs
270 yield self.addProxyArgs(args)
271 args["name"] = build.recipe.store_name or build.recipe.name
272 channels = build.channels or {}
273diff --git a/lib/lp/code/model/cibuildbehaviour.py b/lib/lp/code/model/cibuildbehaviour.py
274index 6a50dd8..def2e95 100644
275--- a/lib/lp/code/model/cibuildbehaviour.py
276+++ b/lib/lp/code/model/cibuildbehaviour.py
277@@ -10,6 +10,7 @@ __all__ = [
278 import json
279 from configparser import NoSectionError
280 from copy import deepcopy
281+from typing import Any, Generator
282
283 from twisted.internet import defer
284 from zope.component import adapter
285@@ -20,6 +21,7 @@ from lp.buildmaster.builderproxy import BuilderProxyMixin
286 from lp.buildmaster.enums import BuildBaseImageType
287 from lp.buildmaster.interfaces.builder import CannotBuild
288 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
289+ BuildArgs,
290 IBuildFarmJobBehaviour,
291 )
292 from lp.buildmaster.model.buildfarmjobbehaviour import (
293@@ -164,7 +166,7 @@ class CIBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
294 )
295
296 @defer.inlineCallbacks
297- def extraBuildArgs(self, logger=None):
298+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
299 """Return extra builder arguments for this build."""
300 build = self.build
301 if not build.stages:
302@@ -173,7 +175,7 @@ class CIBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
303 % (build.git_repository.unique_name, build.commit_sha1)
304 )
305
306- args = yield super().extraBuildArgs(logger=logger)
307+ args = yield super().extraBuildArgs(logger=logger) # type: BuildArgs
308 yield self.addProxyArgs(args)
309 (
310 args["archives"],
311diff --git a/lib/lp/code/model/recipebuilder.py b/lib/lp/code/model/recipebuilder.py
312index 0ca91c0..9b6e49a 100644
313--- a/lib/lp/code/model/recipebuilder.py
314+++ b/lib/lp/code/model/recipebuilder.py
315@@ -7,6 +7,8 @@ __all__ = [
316 "RecipeBuildBehaviour",
317 ]
318
319+from typing import Any, Generator
320+
321 from twisted.internet import defer
322 from zope.component import adapter
323 from zope.interface import implementer
324@@ -14,6 +16,7 @@ from zope.security.proxy import removeSecurityProxy
325
326 from lp.buildmaster.interfaces.builder import CannotBuild
327 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
328+ BuildArgs,
329 IBuildFarmJobBehaviour,
330 )
331 from lp.buildmaster.model.buildfarmjobbehaviour import (
332@@ -53,7 +56,7 @@ class RecipeBuildBehaviour(BuildFarmJobBehaviourBase):
333 return None
334
335 @defer.inlineCallbacks
336- def extraBuildArgs(self, logger=None):
337+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
338 """
339 Return the extra arguments required by the worker for the given build.
340 """
341@@ -67,7 +70,7 @@ class RecipeBuildBehaviour(BuildFarmJobBehaviourBase):
342 )
343
344 # Build extra arguments.
345- args = yield super().extraBuildArgs(logger=logger)
346+ args = yield super().extraBuildArgs(logger=logger) # type: BuildArgs
347 args["suite"] = self.build.distroseries.getSuite(self.build.pocket)
348 requester = self.build.requester
349 if requester.preferredemail is None:
350diff --git a/lib/lp/oci/model/ocirecipebuildbehaviour.py b/lib/lp/oci/model/ocirecipebuildbehaviour.py
351index d35259c..5f026df 100644
352--- a/lib/lp/oci/model/ocirecipebuildbehaviour.py
353+++ b/lib/lp/oci/model/ocirecipebuildbehaviour.py
354@@ -14,6 +14,7 @@ __all__ = [
355 import json
356 import os
357 from datetime import datetime
358+from typing import Any, Generator
359
360 import pytz
361 from twisted.internet import defer
362@@ -25,6 +26,7 @@ from lp.buildmaster.builderproxy import BuilderProxyMixin
363 from lp.buildmaster.enums import BuildBaseImageType
364 from lp.buildmaster.interfaces.builder import BuildDaemonError, CannotBuild
365 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
366+ BuildArgs,
367 IBuildFarmJobBehaviour,
368 )
369 from lp.buildmaster.model.buildfarmjobbehaviour import (
370@@ -130,12 +132,12 @@ class OCIRecipeBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
371 return info
372
373 @defer.inlineCallbacks
374- def extraBuildArgs(self, logger=None):
375+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
376 """
377 Return the extra arguments required by the worker for the given build.
378 """
379 build = self.build
380- args = yield super().extraBuildArgs(logger=logger)
381+ args = yield super().extraBuildArgs(logger=logger) # type: BuildArgs
382 yield self.addProxyArgs(args, build.recipe.allow_internet)
383 # XXX twom 2020-02-17 This may need to be more complex, and involve
384 # distribution name.
385diff --git a/lib/lp/snappy/model/snapbuildbehaviour.py b/lib/lp/snappy/model/snapbuildbehaviour.py
386index 670eb71..7d40251 100644
387--- a/lib/lp/snappy/model/snapbuildbehaviour.py
388+++ b/lib/lp/snappy/model/snapbuildbehaviour.py
389@@ -10,7 +10,7 @@ __all__ = [
390 "SnapBuildBehaviour",
391 ]
392
393-import typing
394+from typing import Any, Generator
395
396 from twisted.internet import defer
397 from zope.component import adapter
398@@ -21,6 +21,7 @@ from lp.buildmaster.builderproxy import BuilderProxyMixin
399 from lp.buildmaster.enums import BuildBaseImageType
400 from lp.buildmaster.interfaces.builder import CannotBuild
401 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
402+ BuildArgs,
403 IBuildFarmJobBehaviour,
404 )
405 from lp.buildmaster.model.buildfarmjobbehaviour import (
406@@ -109,12 +110,12 @@ class SnapBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
407 )
408
409 @defer.inlineCallbacks
410- def extraBuildArgs(self, logger=None) -> typing.Dict[str, typing.Any]:
411+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
412 """
413 Return the extra arguments required by the worker for the given build.
414 """
415 build = self.build # type: ISnapBuild
416- args = yield super().extraBuildArgs(logger=logger)
417+ args = yield super().extraBuildArgs(logger=logger) # type: BuildArgs
418 yield self.addProxyArgs(args, build.snap.allow_internet)
419 args["name"] = build.snap.store_name or build.snap.name
420 channels = build.channels or {}
421diff --git a/lib/lp/soyuz/model/binarypackagebuildbehaviour.py b/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
422index 3878a0f..a038114 100644
423--- a/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
424+++ b/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
425@@ -8,12 +8,14 @@ __all__ = [
426 ]
427
428 from collections import OrderedDict
429+from typing import Any, Generator
430
431 from twisted.internet import defer
432 from zope.interface import implementer
433
434 from lp.buildmaster.interfaces.builder import CannotBuild
435 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
436+ BuildArgs,
437 IBuildFarmJobBehaviour,
438 )
439 from lp.buildmaster.model.buildfarmjobbehaviour import (
440@@ -151,7 +153,7 @@ class BinaryPackageBuildBehaviour(BuildFarmJobBehaviourBase):
441 )
442
443 @defer.inlineCallbacks
444- def extraBuildArgs(self, logger=None):
445+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
446 """
447 Return the extra arguments required by the worker for the given build.
448 """
449@@ -159,7 +161,7 @@ class BinaryPackageBuildBehaviour(BuildFarmJobBehaviourBase):
450 das = build.distro_arch_series
451
452 # Build extra arguments.
453- args = yield super().extraBuildArgs(logger=logger)
454+ args = yield super().extraBuildArgs(logger=logger) # type: BuildArgs
455 args["arch_indep"] = build.arch_indep
456 args["distribution"] = das.distroseries.distribution.name
457 args["suite"] = das.distroseries.getSuite(build.pocket)
458diff --git a/lib/lp/soyuz/model/livefsbuildbehaviour.py b/lib/lp/soyuz/model/livefsbuildbehaviour.py
459index 58aa1fc..d9f1cfd 100644
460--- a/lib/lp/soyuz/model/livefsbuildbehaviour.py
461+++ b/lib/lp/soyuz/model/livefsbuildbehaviour.py
462@@ -10,6 +10,8 @@ __all__ = [
463 "LiveFSBuildBehaviour",
464 ]
465
466+from typing import Any, Generator, cast
467+
468 from twisted.internet import defer
469 from zope.component import adapter
470 from zope.interface import implementer
471@@ -18,6 +20,7 @@ from zope.security.proxy import removeSecurityProxy
472 from lp.buildmaster.enums import BuildBaseImageType
473 from lp.buildmaster.interfaces.builder import CannotBuild
474 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
475+ BuildArgs,
476 IBuildFarmJobBehaviour,
477 )
478 from lp.buildmaster.model.buildfarmjobbehaviour import (
479@@ -93,20 +96,25 @@ class LiveFSBuildBehaviour(BuildFarmJobBehaviourBase):
480 )
481
482 @defer.inlineCallbacks
483- def extraBuildArgs(self, logger=None):
484+ def extraBuildArgs(self, logger=None) -> Generator[Any, Any, BuildArgs]:
485 """
486 Return the extra arguments required by the worker for the given build.
487 """
488 build = self.build
489- base_args = yield super().extraBuildArgs(logger=logger)
490+ base_args = yield super().extraBuildArgs(
491+ logger=logger
492+ ) # type: BuildArgs
493 # Non-trivial metadata values may have been security-wrapped, which
494 # is pointless here and just gets in the way of xmlrpc.client
495 # serialisation.
496- args = dict(removeSecurityProxy(build.livefs.metadata))
497+ args = cast(
498+ BuildArgs, dict(removeSecurityProxy(build.livefs.metadata))
499+ )
500 if build.metadata_override is not None:
501 args.update(removeSecurityProxy(build.metadata_override))
502 # Everything else overrides anything in the metadata.
503- args.update(base_args)
504+ # https://github.com/python/mypy/issues/6462
505+ args.update(base_args) # type: ignore[typeddict-item]
506 args["pocket"] = build.pocket.name.lower()
507 args["datestamp"] = build.version
508 (
509diff --git a/lib/lp/translations/model/translationtemplatesbuildbehaviour.py b/lib/lp/translations/model/translationtemplatesbuildbehaviour.py
510index f159ca2..c2a2f27 100644
511--- a/lib/lp/translations/model/translationtemplatesbuildbehaviour.py
512+++ b/lib/lp/translations/model/translationtemplatesbuildbehaviour.py
513@@ -22,6 +22,7 @@ from zope.interface import implementer
514 from lp.app.interfaces.launchpad import ILaunchpadCelebrities
515 from lp.buildmaster.enums import BuildStatus
516 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
517+ BuildArgs,
518 IBuildFarmJobBehaviour,
519 )
520 from lp.buildmaster.model.buildfarmjobbehaviour import (
521@@ -68,7 +69,7 @@ class TranslationTemplatesBuildBehaviour(BuildFarmJobBehaviourBase):
522 def pocket(self):
523 return PackagePublishingPocket.RELEASE
524
525- def extraBuildArgs(self, logger=None):
526+ def extraBuildArgs(self, logger=None) -> BuildArgs:
527 args = super().extraBuildArgs(logger=logger)
528 args["branch_url"] = self.build.branch.composePublicURL()
529 return args
530diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
531index fe72892..a6e8a51 100644
532--- a/requirements/launchpad.txt
533+++ b/requirements/launchpad.txt
534@@ -174,6 +174,7 @@ treq==18.6.0
535 Twisted==20.3.0+lp9
536 txfixtures==0.4.3
537 txpkgupload==0.4
538+typing-extensions==3.10.0.2
539 urllib3==1.25.11
540 van.testing==3.0.0
541 vine==1.3.0
542diff --git a/setup.cfg b/setup.cfg
543index f3f51e3..f93f218 100644
544--- a/setup.cfg
545+++ b/setup.cfg
546@@ -116,6 +116,7 @@ install_requires =
547 Twisted[conch,tls]
548 txfixtures
549 txpkgupload
550+ typing-extensions
551 virtualenv-tools3
552 wadllib
553 WebOb
554diff --git a/tox.ini b/tox.ini
555index 9d78638..83877d4 100644
556--- a/tox.ini
557+++ b/tox.ini
558@@ -27,7 +27,7 @@ commands_pre =
559 {toxinidir}/scripts/update-version-info.sh
560 commands =
561 mypy --follow-imports=silent \
562- {posargs:lib/lp/answers lib/lp/app lib/lp/archivepublisher lib/lp/archiveuploader lib/lp/buildmaster}
563+ {posargs:lib/lp/answers lib/lp/app lib/lp/archivepublisher lib/lp/archiveuploader lib/lp/buildmaster lib/lp/charms/model/charmrecipebuildbehaviour.py lib/lp/code/model/cibuildbehaviour.py lib/lp/code/model/recipebuilder.py lib/lp/oci/model/ocirecipebuildbehaviour.py lib/lp/snappy/model/snapbuildbehaviour.py lib/lp/soyuz/model/binarypackagebuildbehaviour.py lib/lp/soyuz/model/livefsbuildbehaviour.py lib/lp/translations/model/translationtemplatesbuildbehaviour.py}
564
565 [testenv:docs]
566 basepython = python3

Subscribers

People subscribed via source and target branches

to status/vote changes: