Merge ~adam-collard/maas-ci/+git/system-tests:mypy-cleanup into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 91f7f2f49a3e1b61ac73cfc3dc205f8074570871
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas-ci/+git/system-tests:mypy-cleanup
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 389 lines (+74/-65)
15 files modified
pyproject.toml (+4/-0)
systemtests/conftest.py (+3/-3)
systemtests/lxd.py (+19/-18)
temporal/build_results.py (+1/-1)
temporal/e2e_worker.py (+3/-3)
temporal/e2e_workflow.py (+7/-6)
temporal/image_building_worker.py (+3/-3)
temporal/image_building_workflow.py (+4/-3)
temporal/image_reporting_worker.py (+3/-3)
temporal/image_reporting_workflow.py (+5/-4)
temporal/image_testing_worker.py (+3/-3)
temporal/image_testing_workflow.py (+5/-4)
temporal/monolithic_worker.py (+9/-9)
temporal/test_images.py (+2/-1)
tox.ini (+3/-4)
Reviewer Review Type Date Requested Status
Jack Lloyd-Walters Approve
MAAS Lander Approve
Review via email: mp+455892@code.launchpad.net

Commit message

chore: remove type:ignore from conftest, lxd

move isort config to pyproject.toml

temporal: use relative imports

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b mypy-cleanup lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 91f7f2f49a3e1b61ac73cfc3dc205f8074570871

review: Approve
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/pyproject.toml b/pyproject.toml
2index a3b6850..cdbd428 100644
3--- a/pyproject.toml
4+++ b/pyproject.toml
5@@ -19,3 +19,7 @@ log_file_date_format = "%Y-%m-%d %H:%M:%S"
6 install_types = true
7 non_interactive = true
8 strict = true
9+
10+[tool.isort]
11+profile = "black"
12+src_paths = ["systemtests", "utils", "temporal"]
13diff --git a/systemtests/conftest.py b/systemtests/conftest.py
14index 72957ee..fe750a5 100644
15--- a/systemtests/conftest.py
16+++ b/systemtests/conftest.py
17@@ -197,7 +197,7 @@ def pytest_report_header(config: pytest.Config) -> list[str]:
18
19
20 @pytest.hookimpl(tryfirst=True, hookwrapper=True)
21-def pytest_runtest_makereport(item: Any, call: Any) -> Iterator[Any]:
22+def pytest_runtest_makereport(item: Any, call: Any) -> Iterator[None]:
23 # execute all other hooks to obtain the report object
24 del call
25 outcome: _Result
26@@ -210,10 +210,10 @@ def pytest_runtest_makereport(item: Any, call: Any) -> Iterator[Any]:
27 rep.sections.append(("Test logging", testlog.getvalue()))
28
29
30-@pytest.hookimpl(hookwrapper=True) # type: ignore
31+@pytest.hookimpl(hookwrapper=True)
32 def pytest_terminal_summary(
33 terminalreporter: TerminalReporter, exitstatus: int, config: pytest.Config
34-):
35+) -> Iterator[None]:
36 yield
37 # Split the string up to avoid awk accidentally matching when
38 # traceback is reported
39diff --git a/systemtests/lxd.py b/systemtests/lxd.py
40index 5f7061f..ced4b64 100644
41--- a/systemtests/lxd.py
42+++ b/systemtests/lxd.py
43@@ -255,10 +255,6 @@ class Instance:
44 return _FilesWrapper(self, self._run)
45
46 def get_ip_address(self) -> str:
47- # XXX quieten mypy due to https://github.com/python/mypy/issues/9689
48- @retry(
49- exceptions=ValueError, tries=30, delay=2, backoff=1.1, logger=self.logger
50- ) # type:ignore
51 def _get_ip_address() -> str:
52 result = self._run(
53 [
54@@ -280,7 +276,12 @@ class Instance:
55 f"Unable to find IP address for eth0 on {self._instance_name}"
56 )
57
58- return _get_ip_address()
59+ # mypy workaround due to https://github.com/python/mypy/issues/9689
60+ retriable_get_ip_address = retry(
61+ exceptions=ValueError, tries=30, delay=2, backoff=1.1, logger=self.logger
62+ )(_get_ip_address)
63+
64+ return retriable_get_ip_address()
65
66 def list_devices(self) -> list[str]:
67 result = self._run(["lxc", "config", "device", "list", self._instance_name])
68@@ -303,19 +304,19 @@ class Instance:
69 def remove_device(self, name: str) -> None:
70 """Remove a device from this instance."""
71
72- # XXX quieten mypy due to https://github.com/python/mypy/issues/9689
73- @retry(
74- exceptions=subprocess.CalledProcessError,
75- tries=5,
76- delay=0.5,
77- logger=self.logger,
78- ) # type:ignore
79 def _remove_device() -> subprocess.CompletedProcess[str]:
80 return self._run(
81 ["lxc", "config", "device", "remove", self._instance_name, name],
82 )
83
84- _remove_device()
85+ # mypy workaround due to https://github.com/python/mypy/issues/9689
86+ retriable_remove_device = retry(
87+ exceptions=subprocess.CalledProcessError,
88+ tries=5,
89+ delay=0.5,
90+ logger=self.logger,
91+ )(_remove_device)
92+ retriable_remove_device()
93
94 def start(self) -> subprocess.CompletedProcess[str]:
95 return self._run(["lxc", "start", self._instance_name])
96@@ -408,10 +409,6 @@ class CLILXD:
97 logger.info(f"Container {name} already exists.")
98 logger.info("Waiting for boot to finish...")
99
100- # XXX quieten mypy due to https://github.com/python/mypy/issues/9689
101- @retry(
102- exceptions=CloudInitDisabled, tries=120, delay=1, logger=logger
103- ) # type:ignore
104 def _cloud_init_wait() -> None:
105 """Wait for cloud-init to finish, and for snapd to seed."""
106 cloud_init_process = instance.execute(
107@@ -423,7 +420,11 @@ class CLILXD:
108 ["timeout", "2000", "snap", "wait", "system", "seed.loaded"]
109 )
110
111- _cloud_init_wait()
112+ # mypy workaround due to https://github.com/python/mypy/issues/9689
113+ retriable_cloud_init_wait = retry(
114+ exceptions=CloudInitDisabled, tries=120, delay=1, logger=logger
115+ )(_cloud_init_wait)
116+ retriable_cloud_init_wait()
117 logger.info("Boot finished.")
118 return instance
119
120diff --git a/temporal/build_results.py b/temporal/build_results.py
121index d7ea890..a658d80 100644
122--- a/temporal/build_results.py
123+++ b/temporal/build_results.py
124@@ -7,7 +7,7 @@ from contextlib import contextmanager
125 from dataclasses import dataclass, field
126 from typing import Any, Iterable, Iterator
127
128-from common_tasks import cleanup_files
129+from .common_tasks import cleanup_files
130
131 TestSummary = dict[str, dict[str, Any]]
132 FeatureSummary = dict[str, Any]
133diff --git a/temporal/e2e_worker.py b/temporal/e2e_worker.py
134index 97c5260..7dca420 100644
135--- a/temporal/e2e_worker.py
136+++ b/temporal/e2e_worker.py
137@@ -1,6 +1,6 @@
138-from common_tasks import start_worker
139-from e2e_workflow import activities as e2e_activities
140-from e2e_workflow import workflows as e2e_workflows
141+from .common_tasks import start_worker
142+from .e2e_workflow import activities as e2e_activities
143+from .e2e_workflow import workflows as e2e_workflows
144
145 if __name__ == "__main__":
146 start_worker(
147diff --git a/temporal/e2e_workflow.py b/temporal/e2e_workflow.py
148index 9b874b1..582182a 100644
149--- a/temporal/e2e_workflow.py
150+++ b/temporal/e2e_workflow.py
151@@ -3,14 +3,15 @@ from dataclasses import dataclass, field
152 from typing import Any
153
154 import yaml
155-from build_results import nested_dict, todict
156-from common_tasks import aslist, get_logs, image_name_from_mapping, workflow_parameters
157-from image_building_workflow import image_building_param, image_building_workflow
158-from image_reporting_workflow import image_reporting_param, image_reporting_workflow
159-from image_testing_workflow import image_testing_param, image_testing_workflow
160 from temporalio import activity, workflow
161 from temporalio.common import RetryPolicy
162
163+from .build_results import nested_dict, todict
164+from .common_tasks import aslist, get_logs, image_name_from_mapping, workflow_parameters
165+from .image_building_workflow import image_building_param, image_building_workflow
166+from .image_reporting_workflow import image_reporting_param, image_reporting_workflow
167+from .image_testing_workflow import image_testing_param, image_testing_workflow
168+
169
170 @dataclass
171 class e2e_workflow_params(workflow_parameters):
172@@ -35,7 +36,7 @@ class e2e_workflow_params(workflow_parameters):
173 skip_result_publishing: bool = False
174
175 overwrite_results: bool = False
176- # reccommended to leave this false until the rescue issue at CI is fixed
177+ # recommended to leave this false until the rescue issue at CI is fixed
178 parallel_tests: bool = False
179
180 use_build: int | None = None
181diff --git a/temporal/image_building_worker.py b/temporal/image_building_worker.py
182index 885f578..c3a9961 100644
183--- a/temporal/image_building_worker.py
184+++ b/temporal/image_building_worker.py
185@@ -1,6 +1,6 @@
186-from common_tasks import start_worker
187-from image_building_workflow import activities as image_build_activities
188-from image_building_workflow import workflows as image_build_workflows
189+from .common_tasks import start_worker
190+from .image_building_workflow import activities as image_build_activities
191+from .image_building_workflow import workflows as image_build_workflows
192
193 if __name__ == "__main__":
194 start_worker(
195diff --git a/temporal/image_building_workflow.py b/temporal/image_building_workflow.py
196index 5cbbd8d..bac7ce3 100644
197--- a/temporal/image_building_workflow.py
198+++ b/temporal/image_building_workflow.py
199@@ -2,7 +2,10 @@ import re
200 from dataclasses import dataclass, field
201 from typing import Any
202
203-from common_tasks import (
204+from temporalio import activity, workflow
205+from temporalio.common import RetryPolicy
206+
207+from .common_tasks import (
208 aslist,
209 await_build_complete,
210 await_build_exists,
211@@ -14,8 +17,6 @@ from common_tasks import (
212 request_build,
213 workflow_parameters,
214 )
215-from temporalio import activity, workflow
216-from temporalio.common import RetryPolicy
217
218
219 @dataclass
220diff --git a/temporal/image_reporting_worker.py b/temporal/image_reporting_worker.py
221index bd1f08b..8e0a1ae 100644
222--- a/temporal/image_reporting_worker.py
223+++ b/temporal/image_reporting_worker.py
224@@ -1,6 +1,6 @@
225-from common_tasks import start_worker
226-from image_reporting_workflow import activities as image_reporting_activities
227-from image_reporting_workflow import workflows as image_reporting_workflows
228+from .common_tasks import start_worker
229+from .image_reporting_workflow import activities as image_reporting_activities
230+from .image_reporting_workflow import workflows as image_reporting_workflows
231
232 if __name__ == "__main__":
233 start_worker(
234diff --git a/temporal/image_reporting_workflow.py b/temporal/image_reporting_workflow.py
235index b0ecf8f..5c6a111 100644
236--- a/temporal/image_reporting_workflow.py
237+++ b/temporal/image_reporting_workflow.py
238@@ -5,7 +5,10 @@ from dataclasses import dataclass, field
239 from typing import Any
240
241 import yaml
242-from build_results import (
243+from temporalio import activity, workflow
244+from temporalio.common import RetryPolicy
245+
246+from .build_results import (
247 FeatureStatus,
248 ImageTestResults,
249 checkout_and_commit,
250@@ -15,7 +18,7 @@ from build_results import (
251 execute,
252 get_step_from_results,
253 )
254-from common_tasks import (
255+from .common_tasks import (
256 check_jenkins_reachable,
257 get_build,
258 get_config,
259@@ -23,8 +26,6 @@ from common_tasks import (
260 get_results,
261 workflow_parameters,
262 )
263-from temporalio import activity, workflow
264-from temporalio.common import RetryPolicy
265
266 STEPS_TO_PARSE = ["deploy", "test_image"]
267
268diff --git a/temporal/image_testing_worker.py b/temporal/image_testing_worker.py
269index f28bb23..ebf7a82 100644
270--- a/temporal/image_testing_worker.py
271+++ b/temporal/image_testing_worker.py
272@@ -1,6 +1,6 @@
273-from common_tasks import start_worker
274-from image_testing_workflow import activities as image_test_activities
275-from image_testing_workflow import workflows as image_test_workflows
276+from .common_tasks import start_worker
277+from .image_testing_workflow import activities as image_test_activities
278+from .image_testing_workflow import workflows as image_test_workflows
279
280 if __name__ == "__main__":
281 start_worker(
282diff --git a/temporal/image_testing_workflow.py b/temporal/image_testing_workflow.py
283index 311bf08..3670db5 100644
284--- a/temporal/image_testing_workflow.py
285+++ b/temporal/image_testing_workflow.py
286@@ -1,7 +1,10 @@
287 from dataclasses import dataclass
288 from typing import Any
289
290-from common_tasks import (
291+from temporalio import activity, workflow
292+from temporalio.common import RetryPolicy
293+
294+from .common_tasks import (
295 aslist,
296 await_build_complete,
297 await_build_exists,
298@@ -11,8 +14,6 @@ from common_tasks import (
299 request_build,
300 workflow_parameters,
301 )
302-from temporalio import activity, workflow
303-from temporalio.common import RetryPolicy
304
305
306 @dataclass
307@@ -38,7 +39,7 @@ class image_testing_param(workflow_parameters):
308 @activity.defn
309 async def request_images_test(params: image_testing_param) -> int:
310 """Start an image testing job, returning the job number."""
311- job_params: dict[str, Any] = {
312+ job_params: dict[str, str] = {
313 "IMAGE_NAMES": ",".join(image for image in aslist(params.image_name)),
314 "SYSTEMTESTS_GIT_REPO": params.system_test_repo,
315 "SYSTEMTESTS_GIT_BRANCH": params.system_test_branch,
316diff --git a/temporal/monolithic_worker.py b/temporal/monolithic_worker.py
317index 94f061a..73e4329 100644
318--- a/temporal/monolithic_worker.py
319+++ b/temporal/monolithic_worker.py
320@@ -1,12 +1,12 @@
321-from common_tasks import start_worker
322-from e2e_workflow import activities as e2e_activities
323-from e2e_workflow import workflows as e2e_workflows
324-from image_building_workflow import activities as image_build_activities
325-from image_building_workflow import workflows as image_build_workflows
326-from image_reporting_workflow import activities as image_reporting_activities
327-from image_reporting_workflow import workflows as image_reporting_workflows
328-from image_testing_workflow import activities as image_test_activities
329-from image_testing_workflow import workflows as image_test_workflows
330+from .common_tasks import start_worker
331+from .e2e_workflow import activities as e2e_activities
332+from .e2e_workflow import workflows as e2e_workflows
333+from .image_building_workflow import activities as image_build_activities
334+from .image_building_workflow import workflows as image_build_workflows
335+from .image_reporting_workflow import activities as image_reporting_activities
336+from .image_reporting_workflow import workflows as image_reporting_workflows
337+from .image_testing_workflow import activities as image_test_activities
338+from .image_testing_workflow import workflows as image_test_workflows
339
340 if __name__ == "__main__":
341 start_worker(
342diff --git a/temporal/test_images.py b/temporal/test_images.py
343index c78208a..c6806e6 100644
344--- a/temporal/test_images.py
345+++ b/temporal/test_images.py
346@@ -6,9 +6,10 @@ from datetime import datetime
347 from typing import Any
348
349 import yaml
350-from e2e_workflow import e2e_workflow, e2e_workflow_params
351 from temporalio.client import Client
352
353+from .e2e_workflow import e2e_workflow, e2e_workflow_params
354+
355
356 async def main(
357 params: e2e_workflow_params,
358diff --git a/tox.ini b/tox.ini
359index f347a7b..f11676e 100644
360--- a/tox.ini
361+++ b/tox.ini
362@@ -66,7 +66,7 @@ description=Reformat Python code and README.md
363 deps= -rrequirements.txt
364 skip_install = true
365 commands=
366- isort --profile black systemtests utils temporal
367+ isort systemtests utils temporal
368 black systemtests utils temporal
369 cog -r README.md
370
371@@ -76,7 +76,7 @@ deps= -rrequirements.txt
372 allowlist_externals=sh
373 skip_install = true
374 commands=
375- isort --profile black --check-only systemtests utils temporal
376+ isort --check-only systemtests utils temporal
377 black --check systemtests utils temporal
378 cog --verbosity=0 --check README.md
379 flake8 systemtests utils temporal
380@@ -94,8 +94,7 @@ deps=
381 mypy
382 types-netaddr
383 commands=
384- mypy -p systemtests -p utils --install-types
385- mypy temporal
386+ mypy -p systemtests -p temporal -p utils --install-types
387
388 [testenv:generate_config]
389 description=Generate config.yaml

Subscribers

People subscribed via source and target branches

to all changes: