← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:mypy-buildmaster into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:mypy-buildmaster into launchpad:master.

Commit message:
mypy: Run for lp.buildmaster

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/435088

Also fix `tox -e mypy` to work with tox 4.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:mypy-buildmaster into launchpad:master.
diff --git a/lib/lp/buildmaster/downloader.py b/lib/lp/buildmaster/downloader.py
index 527842d..4c9fa13 100644
--- a/lib/lp/buildmaster/downloader.py
+++ b/lib/lp/buildmaster/downloader.py
@@ -15,6 +15,7 @@ __all__ = [
 
 import os.path
 import tempfile
+from typing import List, Tuple
 
 from ampoule.child import AMPChild
 from requests import RequestException, Session
@@ -30,7 +31,7 @@ class DownloadCommand(amp.Command):
         (b"path_to_write", amp.Unicode()),
         (b"timeout", amp.Integer()),
     ]
-    response = []
+    response = []  # type: List[Tuple[bytes, amp.Argument]]
     errors = {
         RequestException: b"REQUEST_ERROR",
         StreamingError: b"STREAMING_ERROR",
diff --git a/lib/lp/buildmaster/tests/mock_workers.py b/lib/lp/buildmaster/tests/mock_workers.py
index 55ac82d..1840d4b 100644
--- a/lib/lp/buildmaster/tests/mock_workers.py
+++ b/lib/lp/buildmaster/tests/mock_workers.py
@@ -27,7 +27,7 @@ from textwrap import dedent
 try:
     from importlib import resources
 except ImportError:
-    import importlib_resources as resources
+    import importlib_resources as resources  # type: ignore
 
 import fixtures
 from testtools.content import attach_file
diff --git a/lib/lp/buildmaster/tests/test_buildfarmjob.py b/lib/lp/buildmaster/tests/test_buildfarmjob.py
index 68f9335..994e3a9 100644
--- a/lib/lp/buildmaster/tests/test_buildfarmjob.py
+++ b/lib/lp/buildmaster/tests/test_buildfarmjob.py
@@ -4,6 +4,7 @@
 """Tests for `IBuildFarmJob`."""
 
 from datetime import datetime, timedelta
+from typing import Type
 
 import pytz
 from storm.store import Store
@@ -23,16 +24,20 @@ from lp.buildmaster.interfaces.buildfarmjob import (
 from lp.buildmaster.model.buildfarmjob import BuildFarmJob
 from lp.services.database.sqlbase import flush_database_updates
 from lp.testing import TestCaseWithFactory, admin_logged_in, login
-from lp.testing.layers import DatabaseFunctionalLayer, LaunchpadFunctionalLayer
+from lp.testing.layers import (
+    BaseLayer,
+    DatabaseFunctionalLayer,
+    LaunchpadFunctionalLayer,
+)
 
 
 class TestBuildFarmJobBase:
 
-    layer = DatabaseFunctionalLayer
+    layer = DatabaseFunctionalLayer  # type: Type[BaseLayer]
 
-    def setUp(self):
+    def setUp(self, *args, **kwargs):
         """Create a build farm job with which to test."""
-        super().setUp()
+        super().setUp(*args, **kwargs)
         self.build_farm_job = self.makeBuildFarmJob()
 
     def makeBuildFarmJob(
diff --git a/lib/lp/buildmaster/tests/test_manager.py b/lib/lp/buildmaster/tests/test_manager.py
index 7c98f0d..0b93e76 100644
--- a/lib/lp/buildmaster/tests/test_manager.py
+++ b/lib/lp/buildmaster/tests/test_manager.py
@@ -7,6 +7,7 @@ import os
 import signal
 import time
 import xmlrpc.client
+from typing import Dict
 from unittest import mock
 
 import transaction
@@ -1013,7 +1014,7 @@ class TestPrefetchedBuilderFactory(TestCaseWithFactory):
 class FakeBuilddManager:
     """A minimal fake version of `BuilddManager`."""
 
-    pending_logtails = {}
+    pending_logtails = {}  # type: Dict[int, str]
 
     def addLogTail(self, build_queue_id, logtail):
         self.pending_logtails[build_queue_id] = logtail
diff --git a/pyproject.toml b/pyproject.toml
index e553c39..83925c3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,6 +10,10 @@ exclude = [
 ]
 
 [[tool.mypy.overrides]]
+module = "ampoule.*"
+ignore_missing_imports = true
+
+[[tool.mypy.overrides]]
 module = "apt_inst"
 ignore_missing_imports = true
 
@@ -62,6 +66,10 @@ module = "lazr.*"
 ignore_missing_imports = true
 
 [[tool.mypy.overrides]]
+module = "lpbuildd.*"
+ignore_missing_imports = true
+
+[[tool.mypy.overrides]]
 module = "packaging"
 ignore_missing_imports = true
 
@@ -74,6 +82,10 @@ module = "pystache"
 ignore_missing_imports = true
 
 [[tool.mypy.overrides]]
+module = "requests_toolbelt.*"
+ignore_missing_imports = true
+
+[[tool.mypy.overrides]]
 module = "responses"
 ignore_missing_imports = true
 
@@ -106,6 +118,10 @@ module = "twisted.*"
 ignore_missing_imports = true
 
 [[tool.mypy.overrides]]
+module = "txfixtures.*"
+ignore_missing_imports = true
+
+[[tool.mypy.overrides]]
 module = "zope.*"
 ignore_missing_imports = true
 
diff --git a/tox.ini b/tox.ini
index 30758fb..9d78638 100644
--- a/tox.ini
+++ b/tox.ini
@@ -21,11 +21,13 @@ skip_install = true
 deps =
     mypy
     -r requirements/types.txt
+allowlist_externals =
+    {toxinidir}/scripts/update-version-info.sh
 commands_pre =
     {toxinidir}/scripts/update-version-info.sh
 commands =
     mypy --follow-imports=silent \
-    {posargs:lib/lp/answers lib/lp/app lib/lp/archivepublisher lib/lp/archiveuploader}
+    {posargs:lib/lp/answers lib/lp/app lib/lp/archivepublisher lib/lp/archiveuploader lib/lp/buildmaster}
 
 [testenv:docs]
 basepython = python3

Follow ups