You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2022/04/05 10:04:57 UTC

[buildstream-plugins] 42/49: tox.ini: Updating black to version 22.3.0

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git

commit 817e24b711f5bb220b83b9ddaee2042397d432d8
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Thu Mar 31 18:14:29 2022 +0900

    tox.ini: Updating black to version 22.3.0
    
    This is required to avoid a recently occurring exception when running black,
    as outlined here: https://github.com/psf/black/issues/2964
---
 setup.py                                  | 13 ++++-
 src/buildstream_plugins/sources/bzr.py    | 43 +++++++++++---
 src/buildstream_plugins/sources/cargo.py  | 34 +++++++++--
 src/buildstream_plugins/sources/docker.py | 39 +++++++++----
 src/buildstream_plugins/sources/git.py    | 96 ++++++++++++++++++++++++++-----
 src/buildstream_plugins/sources/patch.py  | 12 +++-
 src/buildstream_plugins/sources/pip.py    |  5 +-
 tests/conftest.py                         |  5 +-
 tests/elements/cmake.py                   | 10 +++-
 tests/elements/make.py                    |  5 +-
 tests/elements/meson.py                   | 10 +++-
 tests/elements/pip.py                     | 26 +++++++--
 tests/elements/setuptools.py              |  5 +-
 tests/sources/git.py                      |  5 +-
 tests/sources/patch.py                    |  5 +-
 tests/sources/pip.py                      | 31 ++++++++--
 tests/sources/pip_build.py                | 25 ++++++--
 tests/testutils/python_repo.py            | 14 ++++-
 tests/testutils/repo/bzrrepo.py           | 12 +++-
 tests/testutils/repo/gitrepo.py           | 14 ++++-
 tox.ini                                   |  4 +-
 21 files changed, 337 insertions(+), 76 deletions(-)

diff --git a/setup.py b/setup.py
index a988e40..44d1b23 100755
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,10 @@ except ImportError:
 ###############################################################################
 #                             Parse README                                    #
 ###############################################################################
-with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "README.rst"), encoding="utf-8",) as readme:
+with open(
+    os.path.join(os.path.dirname(os.path.realpath(__file__)), "README.rst"),
+    encoding="utf-8",
+) as readme:
     long_description = readme.read()
 
 
@@ -57,7 +60,9 @@ setup(
     long_description_content_type="text/x-rst; charset=UTF-8",
     license="Apache License Version 2.0",
     url="https://buildstream.build",
-    project_urls={"Documentation": "https://docs.buildstream.build/",},
+    project_urls={
+        "Documentation": "https://docs.buildstream.build/",
+    },
     package_dir={"": "src"},
     packages=find_packages(where="src"),
     include_package_data=True,
@@ -80,7 +85,9 @@ setup(
             "zip = buildstream_plugins.sources.zip",
         ],
     },
-    extras_require={"cargo": ["toml"],},
+    extras_require={
+        "cargo": ["toml"],
+    },
     zip_safe=False,
 )
 # eof setup()
diff --git a/src/buildstream_plugins/sources/bzr.py b/src/buildstream_plugins/sources/bzr.py
index c768b35..b7de232 100644
--- a/src/buildstream_plugins/sources/bzr.py
+++ b/src/buildstream_plugins/sources/bzr.py
@@ -100,7 +100,13 @@ class BzrSource(Source):
         with self.timed_activity("Tracking {}".format(self.url), silent_nested=True), self._locked():
             self._ensure_mirror(skip_ref_check=True)
             ret, out = self.check_output(
-                [self.host_bzr, "version-info", "--custom", "--template={revno}", self._get_branch_dir(),],
+                [
+                    self.host_bzr,
+                    "version-info",
+                    "--custom",
+                    "--template={revno}",
+                    self._get_branch_dir(),
+                ],
                 fail="Failed to read the revision number at '{}'".format(self._get_branch_dir()),
             )
             if ret != 0:
@@ -148,7 +154,12 @@ class BzrSource(Source):
             )
             # Switch the parent branch to the source's origin
             self.call(
-                [self.host_bzr, "switch", "--directory={}".format(directory), url,],
+                [
+                    self.host_bzr,
+                    "switch",
+                    "--directory={}".format(directory),
+                    url,
+                ],
                 fail="Failed to switch workspace's parent branch to {}".format(url),
             )
 
@@ -175,21 +186,33 @@ class BzrSource(Source):
             return False
 
         return (
-            self.call([self.host_bzr, "revno", "--revision=revno:{}".format(self.ref), self._get_branch_dir(),]) == 0
+            self.call(
+                [
+                    self.host_bzr,
+                    "revno",
+                    "--revision=revno:{}".format(self.ref),
+                    self._get_branch_dir(),
+                ]
+            )
+            == 0
         )
 
     def _get_branch_dir(self):
         return os.path.join(self._get_mirror_dir(), self.tracking)
 
     def _get_mirror_dir(self):
-        return os.path.join(self.get_mirror_directory(), utils.url_directory_name(self.original_url),)
+        return os.path.join(
+            self.get_mirror_directory(),
+            utils.url_directory_name(self.original_url),
+        )
 
     def _ensure_mirror(self, skip_ref_check=False):
         mirror_dir = self._get_mirror_dir()
         bzr_metadata_dir = os.path.join(mirror_dir, ".bzr")
         if not os.path.exists(bzr_metadata_dir):
             self.call(
-                [self.host_bzr, "init-repo", "--no-trees", mirror_dir], fail="Failed to initialize bzr repository",
+                [self.host_bzr, "init-repo", "--no-trees", mirror_dir],
+                fail="Failed to initialize bzr repository",
             )
 
         branch_dir = os.path.join(mirror_dir, self.tracking)
@@ -206,13 +229,19 @@ class BzrSource(Source):
             # `bzr pull` the branch if it does exist
             # to get any changes to the upstream code
             self.call(
-                [self.host_bzr, "pull", "--directory={}".format(branch_dir), branch_url,],
+                [
+                    self.host_bzr,
+                    "pull",
+                    "--directory={}".format(branch_dir),
+                    branch_url,
+                ],
                 fail="Failed to pull new changes for {}".format(branch_dir),
             )
 
         if not skip_ref_check and not self._check_ref():
             raise SourceError(
-                "Failed to ensure ref '{}' was mirrored".format(self.ref), reason="ref-not-mirrored",
+                "Failed to ensure ref '{}' was mirrored".format(self.ref),
+                reason="ref-not-mirrored",
             )
 
 
diff --git a/src/buildstream_plugins/sources/cargo.py b/src/buildstream_plugins/sources/cargo.py
index bebc305..705f2a1 100644
--- a/src/buildstream_plugins/sources/cargo.py
+++ b/src/buildstream_plugins/sources/cargo.py
@@ -234,10 +234,20 @@ class Crate(SourceFetcher):
                 # Because we use etag only for matching sha, currently specified sha is what
                 # we would have downloaded.
                 return self.sha
-            raise SourceError("{}: Error mirroring {}: {}".format(self, url, e), temporary=True,) from e
+            raise SourceError(
+                "{}: Error mirroring {}: {}".format(self, url, e),
+                temporary=True,
+            ) from e
 
-        except (urllib.error.URLError, urllib.error.ContentTooShortError, OSError,) as e:
-            raise SourceError("{}: Error mirroring {}: {}".format(self, url, e), temporary=True,) from e
+        except (
+            urllib.error.URLError,
+            urllib.error.ContentTooShortError,
+            OSError,
+        ) as e:
+            raise SourceError(
+                "{}: Error mirroring {}: {}".format(self, url, e),
+                temporary=True,
+            ) from e
 
     # _get_url()
     #
@@ -292,7 +302,10 @@ class Crate(SourceFetcher):
     #
     def _get_mirror_dir(self):
         return os.path.join(
-            self.cargo.get_mirror_directory(), utils.url_directory_name(self.cargo.url), self.name, self.version,
+            self.cargo.get_mirror_directory(),
+            utils.url_directory_name(self.cargo.url),
+            self.name,
+            self.version,
         )
 
     # _get_mirror_file()
@@ -365,7 +378,8 @@ class CargoSource(Source):
                     lock = toml.load(f)
                 except toml.TomlDecodeError as e:
                     raise SourceError(
-                        "Malformed Cargo.lock file at: {}".format(self.cargo_lock), detail="{}".format(e),
+                        "Malformed Cargo.lock file at: {}".format(self.cargo_lock),
+                        detail="{}".format(e),
                     ) from e
         except FileNotFoundError as e:
             raise SourceError(
@@ -435,7 +449,15 @@ class CargoSource(Source):
         if refs is None:
             return []
 
-        return [Crate(self, crate["name"], crate["version"], sha=crate.get("sha", None),) for crate in refs]
+        return [
+            Crate(
+                self,
+                crate["name"],
+                crate["version"],
+                sha=crate.get("sha", None),
+            )
+            for crate in refs
+        ]
 
 
 def setup():
diff --git a/src/buildstream_plugins/sources/docker.py b/src/buildstream_plugins/sources/docker.py
index 4b2afde..eeaa1cf 100644
--- a/src/buildstream_plugins/sources/docker.py
+++ b/src/buildstream_plugins/sources/docker.py
@@ -207,7 +207,11 @@ class DockerRegistryV2Client:
     # Returns:
     #    (str, str): A tuple of the manifest content as text, and its content hash
     def manifest(
-        self, image_path, reference, architecture=default_architecture(), os_=default_os(),
+        self,
+        image_path,
+        reference,
+        architecture=default_architecture(),
+        os_=default_os(),
     ):
         # pylint: disable=too-many-locals
 
@@ -223,7 +227,8 @@ class DockerRegistryV2Client:
             manifest = json.loads(response.text)
         except json.JSONDecodeError as e:
             raise DockerManifestError(
-                "Server did not return a valid manifest: {}".format(e), manifest=response.text,
+                "Server did not return a valid manifest: {}".format(e),
+                manifest=response.text,
             ) from e
 
         schema_version = manifest.get("schemaVersion")
@@ -231,7 +236,8 @@ class DockerRegistryV2Client:
             raise DockerManifestError("Schema version 1 is unsupported.", manifest=response.text)
         if schema_version is None:
             raise DockerManifestError(
-                "Manifest did not include the schemaVersion key.", manifest=response.text,
+                "Manifest did not include the schemaVersion key.",
+                manifest=response.text,
             )
 
         our_digest = self.digest(response.text.encode("utf8"))
@@ -239,7 +245,8 @@ class DockerRegistryV2Client:
 
         if not their_digest:
             raise DockerManifestError(
-                "Server did not set the Docker-Content-Digest header.", manifest=response.text,
+                "Server did not set the Docker-Content-Digest header.",
+                manifest=response.text,
             )
         if our_digest != their_digest:
             raise DockerManifestError(
@@ -254,16 +261,23 @@ class DockerRegistryV2Client:
             for sub in manifest["manifests"]:
                 if sub["platform"]["architecture"] == architecture and sub["platform"]["os"]:
                     sub_digest = sub["digest"]
-                    return self.manifest(image_path, sub_digest, architecture=architecture, os_=os_,)
+                    return self.manifest(
+                        image_path,
+                        sub_digest,
+                        architecture=architecture,
+                        os_=os_,
+                    )
                 else:
                     raise DockerManifestError(
-                        "No images found for architecture {}, OS {}".format(architecture, os_), manifest=response.text,
+                        "No images found for architecture {}, OS {}".format(architecture, os_),
+                        manifest=response.text,
                     )
         elif manifest["mediaType"] == "application/vnd.docker.distribution.manifest.v2+json":
             return response.text, our_digest
         else:
             raise DockerManifestError(
-                "Unsupported manifest type {}".format(manifest["mediaType"]), manifest=response.text,
+                "Unsupported manifest type {}".format(manifest["mediaType"]),
+                manifest=response.text,
             )
 
     # blob():
@@ -440,7 +454,8 @@ class DockerSource(Source):
         # pylint: disable=arguments-differ
 
         with self.timed_activity(
-            "Fetching image {}:{} with digest {}".format(self.image, self.tag, self.digest), silent_nested=True,
+            "Fetching image {}:{} with digest {}".format(self.image, self.tag, self.digest),
+            silent_nested=True,
         ):
             with self.tempdir() as tmpdir:
                 # move all files to a tmpdir
@@ -487,7 +502,8 @@ class DockerSource(Source):
                 # a flat mirror directory. We check one-by-one if there is any need to copy a file out of the tmpdir.
                 for fetched_file in os.listdir(tmpdir):
                     move_atomic(
-                        os.path.join(tmpdir, fetched_file), os.path.join(self.get_mirror_directory(), fetched_file),
+                        os.path.join(tmpdir, fetched_file),
+                        os.path.join(self.get_mirror_directory(), fetched_file),
                     )
 
     def stage(self, directory):
@@ -504,7 +520,10 @@ class DockerSource(Source):
                 blob_path = os.path.join(mirror_dir, layer_digest + ".tar.gz")
 
                 self._verify_blob(blob_path, expected_digest=layer_digest)
-                (extract_fileset, white_out_fileset,) = self._get_extract_and_remove_files(blob_path)
+                (
+                    extract_fileset,
+                    white_out_fileset,
+                ) = self._get_extract_and_remove_files(blob_path)
 
                 # remove files associated with whiteouts
                 for white_out_file in white_out_fileset:
diff --git a/src/buildstream_plugins/sources/git.py b/src/buildstream_plugins/sources/git.py
index 5d7603d..decd2ec 100644
--- a/src/buildstream_plugins/sources/git.py
+++ b/src/buildstream_plugins/sources/git.py
@@ -226,7 +226,8 @@ class GitMirror(SourceFetcher):
         if not os.path.exists(self.mirror):
             with self.source.tempdir() as tmpdir:
                 self.source.call(
-                    [self.source.host_git, "init", "--bare", tmpdir], fail="Failed to initialise repository",
+                    [self.source.host_git, "init", "--bare", tmpdir],
+                    fail="Failed to initialise repository",
                 )
 
                 try:
@@ -374,7 +375,15 @@ class GitMirror(SourceFetcher):
     #
     def describe(self, rev):
         _, output = self.source.check_output(
-            [self.source.host_git, "describe", "--tags", "--abbrev=40", "--long", "--always", rev,],
+            [
+                self.source.host_git,
+                "describe",
+                "--tags",
+                "--abbrev=40",
+                "--long",
+                "--always",
+                rev,
+            ],
             fail="Unable to find revision {}".format(rev),
             cwd=self.mirror,
         )
@@ -400,7 +409,14 @@ class GitMirror(SourceFetcher):
             ["--tags", "--first-parent"],
         ]:
             exit_code, output = self.source.check_output(
-                [self.source.host_git, "describe", "--abbrev=0", rev, *options,], cwd=self.mirror,
+                [
+                    self.source.host_git,
+                    "describe",
+                    "--abbrev=0",
+                    rev,
+                    *options,
+                ],
+                cwd=self.mirror,
             )
             if exit_code == 0:
                 tag = output.strip()
@@ -409,7 +425,10 @@ class GitMirror(SourceFetcher):
                     fail="Unable to resolve tag '{}'".format(tag),
                     cwd=self.mirror,
                 )
-                exit_code = self.source.call([self.source.host_git, "cat-file", "tag", tag], cwd=self.mirror,)
+                exit_code = self.source.call(
+                    [self.source.host_git, "cat-file", "tag", tag],
+                    cwd=self.mirror,
+                )
                 annotated = exit_code == 0
 
                 tags.add((tag, commit_ref.strip(), annotated))
@@ -423,7 +442,14 @@ class GitMirror(SourceFetcher):
         # case we're just checking out a specific commit and then removing the .git/
         # directory.
         self.source.call(
-            [self.source.host_git, "clone", "--no-checkout", "--shared", self.mirror, fullpath,],
+            [
+                self.source.host_git,
+                "clone",
+                "--no-checkout",
+                "--shared",
+                self.mirror,
+                fullpath,
+            ],
             fail="Failed to create git mirror {} in directory: {}".format(self.mirror, fullpath),
             fail_temporarily=True,
         )
@@ -444,7 +470,13 @@ class GitMirror(SourceFetcher):
         url = self.source.translate_url(self.url)
 
         self.source.call(
-            [self.source.host_git, "clone", "--no-checkout", self.mirror, fullpath,],
+            [
+                self.source.host_git,
+                "clone",
+                "--no-checkout",
+                self.mirror,
+                fullpath,
+            ],
             fail="Failed to clone git mirror {} in directory: {}".format(self.mirror, fullpath),
             fail_temporarily=True,
         )
@@ -596,13 +628,24 @@ class GitMirror(SourceFetcher):
                     )
                     commit_file.seek(0, 0)
                     self.source.call(
-                        [self.source.host_git, "hash-object", "-w", "-t", "commit", "--stdin",],
+                        [
+                            self.source.host_git,
+                            "hash-object",
+                            "-w",
+                            "-t",
+                            "commit",
+                            "--stdin",
+                        ],
                         stdin=commit_file,
                         fail="Failed to add commit object {}".format(rev),
                         cwd=fullpath,
                     )
 
-            with open(os.path.join(fullpath, ".git", "shallow"), "w", encoding="utf-8",) as shallow_file:
+            with open(
+                os.path.join(fullpath, ".git", "shallow"),
+                "w",
+                encoding="utf-8",
+            ) as shallow_file:
                 for rev in shallow:
                     shallow_file.write("{}\n".format(rev))
 
@@ -613,7 +656,14 @@ class GitMirror(SourceFetcher):
                         tag_file.write(tag_data.encode("ascii"))
                         tag_file.seek(0, 0)
                         _, tag_ref = self.source.check_output(
-                            [self.source.host_git, "hash-object", "-w", "-t", "tag", "--stdin",],
+                            [
+                                self.source.host_git,
+                                "hash-object",
+                                "-w",
+                                "-t",
+                                "tag",
+                                "--stdin",
+                            ],
                             stdin=tag_file,
                             fail="Failed to add tag object {}".format(tag),
                             cwd=fullpath,
@@ -677,7 +727,8 @@ class GitSource(Source):
         # If it is missing both then we will be unable to track or build.
         if self.mirror.ref is None and self.tracking is None:
             raise SourceError(
-                "{}: Git sources require a ref and/or track".format(self), reason="missing-track-and-ref",
+                "{}: Git sources require a ref and/or track".format(self),
+                reason="missing-track-and-ref",
             )
 
         self.checkout_submodules = node.get_bool("checkout-submodules", default=True)
@@ -791,14 +842,17 @@ class GitSource(Source):
             if self.mirror.ref is None:
                 detail = "Without a tracking branch ref can not be updated. Please " + "provide a ref or a track."
                 raise SourceError(
-                    "{}: No track or ref".format(self), detail=detail, reason="track-attempt-no-track",
+                    "{}: No track or ref".format(self),
+                    detail=detail,
+                    reason="track-attempt-no-track",
                 )
             return None
 
         # Resolve the URL for the message
         resolved_url = self.translate_url(self.mirror.url)
         with self.timed_activity(
-            "Tracking {} from {}".format(self.tracking, resolved_url), silent_nested=True,
+            "Tracking {} from {}".format(self.tracking, resolved_url),
+            silent_nested=True,
         ):
             self.mirror._fetch(resolved_url, fetch_all=True)
 
@@ -884,14 +938,28 @@ class GitSource(Source):
         ref_in_track = False
         if not re.match(EXACT_TAG_PATTERN, self.mirror.ref) and self.tracking:
             _, branch = self.check_output(
-                [self.host_git, "branch", "--list", self.tracking, "--contains", self.mirror.ref,],
+                [
+                    self.host_git,
+                    "branch",
+                    "--list",
+                    self.tracking,
+                    "--contains",
+                    self.mirror.ref,
+                ],
                 cwd=self.mirror.mirror,
             )
             if branch:
                 ref_in_track = True
             else:
                 _, tag = self.check_output(
-                    [self.host_git, "tag", "--list", self.tracking, "--contains", self.mirror.ref,],
+                    [
+                        self.host_git,
+                        "tag",
+                        "--list",
+                        self.tracking,
+                        "--contains",
+                        self.mirror.ref,
+                    ],
                     cwd=self.mirror.mirror,
                 )
                 if tag:
diff --git a/src/buildstream_plugins/sources/patch.py b/src/buildstream_plugins/sources/patch.py
index 2228723..e664005 100644
--- a/src/buildstream_plugins/sources/patch.py
+++ b/src/buildstream_plugins/sources/patch.py
@@ -95,12 +95,20 @@ class PatchSource(Source):
             # Bail out with a comprehensive message if the target directory is empty
             if not os.listdir(directory):
                 raise SourceError(
-                    "Nothing to patch in directory '{}'".format(directory), reason="patch-no-files",
+                    "Nothing to patch in directory '{}'".format(directory),
+                    reason="patch-no-files",
                 )
 
             strip_level_option = "-p{}".format(self.strip_level)
             self.call(
-                [self.host_patch, strip_level_option, "-i", self.fullpath, "-d", directory,],
+                [
+                    self.host_patch,
+                    strip_level_option,
+                    "-i",
+                    self.fullpath,
+                    "-d",
+                    directory,
+                ],
                 fail="Failed to apply patch {}".format(self.path),
             )
 
diff --git a/src/buildstream_plugins/sources/pip.py b/src/buildstream_plugins/sources/pip.py
index 21e26a0..32384af 100644
--- a/src/buildstream_plugins/sources/pip.py
+++ b/src/buildstream_plugins/sources/pip.py
@@ -92,7 +92,10 @@ _PYTHON_VERSIONS = [
 # https://docs.python.org/3/distutils/sourcedist.html.
 # Names of source distribution archives must be of the form
 # '%{package-name}-%{version}.%{extension}'.
-_SDIST_RE = re.compile(r"^([\w.-]+?)-((?:[\d.]+){2,})\.(?:tar|tar.bz2|tar.gz|tar.xz|tar.Z|zip)$", re.IGNORECASE,)
+_SDIST_RE = re.compile(
+    r"^([\w.-]+?)-((?:[\d.]+){2,})\.(?:tar|tar.bz2|tar.gz|tar.xz|tar.Z|zip)$",
+    re.IGNORECASE,
+)
 
 
 class PipSource(Source):
diff --git a/tests/conftest.py b/tests/conftest.py
index 833c9bb..9f30476 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -11,7 +11,10 @@ from .testutils.repo import Bzr, Git
 #################################################
 def pytest_addoption(parser):
     parser.addoption(
-        "--integration", action="store_true", default=False, help="Run integration tests",
+        "--integration",
+        action="store_true",
+        default=False,
+        help="Run integration tests",
     )
 
 
diff --git a/tests/elements/cmake.py b/tests/elements/cmake.py
index a409ac1..1cd9230 100644
--- a/tests/elements/cmake.py
+++ b/tests/elements/cmake.py
@@ -25,7 +25,10 @@ def test_cmake_build(cli, datafiles):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
@@ -41,7 +44,10 @@ def test_cmake_confroot_build(cli, datafiles):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
diff --git a/tests/elements/make.py b/tests/elements/make.py
index 4edb513..15923d7 100644
--- a/tests/elements/make.py
+++ b/tests/elements/make.py
@@ -27,7 +27,10 @@ def test_make_build(cli, datafiles):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
diff --git a/tests/elements/meson.py b/tests/elements/meson.py
index ac11fab..46328d3 100644
--- a/tests/elements/meson.py
+++ b/tests/elements/meson.py
@@ -25,7 +25,10 @@ def test_meson_build(cli, datafiles):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
@@ -41,7 +44,10 @@ def test_meson_confroot_build(cli, datafiles):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
diff --git a/tests/elements/pip.py b/tests/elements/pip.py
index 1664063..700b9ca 100644
--- a/tests/elements/pip.py
+++ b/tests/elements/pip.py
@@ -42,18 +42,29 @@ def test_pip_build(cli, datafiles):
         ],
     }
     os.makedirs(
-        os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True,
+        os.path.dirname(os.path.join(element_path, element_name)),
+        exist_ok=True,
     )
     _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
 
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(
-        checkout, ["/usr", "/usr/lib", "/usr/bin", "/usr/bin/hello", "/usr/lib/python3.6",],
+        checkout,
+        [
+            "/usr",
+            "/usr/lib",
+            "/usr/bin",
+            "/usr/bin/hello",
+            "/usr/lib/python3.6",
+        ],
     )
 
 
@@ -96,7 +107,8 @@ def test_pip_element_should_install_pip_deps(cli, datafiles, setup_pypi_repo):
     pypi_repo = os.path.join(project, "files", "pypi-repo")
     os.makedirs(pypi_repo, exist_ok=True)
     os.makedirs(
-        os.path.dirname(os.path.join(elements_path, element_name)), exist_ok=True,
+        os.path.dirname(os.path.join(elements_path, element_name)),
+        exist_ok=True,
     )
     setup_pypi_repo(mock_packages, pypi_repo)
 
@@ -112,7 +124,11 @@ def test_pip_element_should_install_pip_deps(cli, datafiles, setup_pypi_repo):
                 # FIXME: remove hardcoded ref once issue #1010 is closed
                 "ref": "ad96570b552498807abec33c06210bf68378d854ced6753b77916c5ed517610d",
             },
-            {"kind": "pip", "url": "file://{}".format(os.path.realpath(pypi_repo)), "packages": [myreqs_packages],},
+            {
+                "kind": "pip",
+                "url": "file://{}".format(os.path.realpath(pypi_repo)),
+                "packages": [myreqs_packages],
+            },
         ],
     }
     _yaml.roundtrip_dump(element, os.path.join(elements_path, element_name))
diff --git a/tests/elements/setuptools.py b/tests/elements/setuptools.py
index 837aa2b..1580e4d 100644
--- a/tests/elements/setuptools.py
+++ b/tests/elements/setuptools.py
@@ -25,7 +25,10 @@ def test_setuptools_build(cli, datafiles):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
diff --git a/tests/sources/git.py b/tests/sources/git.py
index beab0e6..385ea31 100644
--- a/tests/sources/git.py
+++ b/tests/sources/git.py
@@ -37,7 +37,10 @@ from buildstream._testing import create_repo
 
 from tests.testutils.site import HAVE_GIT, HAVE_OLD_GIT
 
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "git",)
+DATA_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)),
+    "git",
+)
 
 
 @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
diff --git a/tests/sources/patch.py b/tests/sources/patch.py
index 91848f1..4d1515a 100644
--- a/tests/sources/patch.py
+++ b/tests/sources/patch.py
@@ -8,7 +8,10 @@ import pytest
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream._testing import cli  # pylint: disable=unused-import
 
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "patch",)
+DATA_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)),
+    "patch",
+)
 
 
 # generate_file_types()
diff --git a/tests/sources/pip.py b/tests/sources/pip.py
index bf30b20..c316296 100644
--- a/tests/sources/pip.py
+++ b/tests/sources/pip.py
@@ -9,7 +9,10 @@ from buildstream.exceptions import ErrorDomain
 from buildstream._testing import cli  # pylint: disable=unused-import
 from buildstream_plugins.sources.pip import _match_package_name
 
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pip",)
+DATA_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)),
+    "pip",
+)
 
 
 def generate_project(project_dir):
@@ -18,7 +21,13 @@ def generate_project(project_dir):
         {
             "name": "foo",
             "min-version": "2.0",
-            "plugins": [{"origin": "pip", "package-name": "buildstream-plugins", "sources": ["pip"],}],
+            "plugins": [
+                {
+                    "origin": "pip",
+                    "package-name": "buildstream-plugins",
+                    "sources": ["pip"],
+                }
+            ],
         },
         project_file,
     )
@@ -59,9 +68,21 @@ def test_no_packages(cli, datafiles):
         ("hyphenated-package-2.6.0.tar.gz", "hyphenated-package", "2.6.0"),
         ("underscore_pkg-3.1.0.tar.gz", "underscore_pkg", "3.1.0"),
         ("numbers2and5-1.0.1.tar.gz", "numbers2and5", "1.0.1"),
-        ("multiple.dots.package-5.6.7.tar.gz", "multiple.dots.package", "5.6.7",),
-        ("multiple-hyphens-package-1.2.3.tar.gz", "multiple-hyphens-package", "1.2.3",),
-        ("multiple_underscore_pkg-3.4.5.tar.gz", "multiple_underscore_pkg", "3.4.5",),
+        (
+            "multiple.dots.package-5.6.7.tar.gz",
+            "multiple.dots.package",
+            "5.6.7",
+        ),
+        (
+            "multiple-hyphens-package-1.2.3.tar.gz",
+            "multiple-hyphens-package",
+            "1.2.3",
+        ),
+        (
+            "multiple_underscore_pkg-3.4.5.tar.gz",
+            "multiple_underscore_pkg",
+            "3.4.5",
+        ),
         ("shortversion-1.0.tar.gz", "shortversion", "1.0"),
         ("longversion-1.2.3.4.tar.gz", "longversion", "1.2.3.4"),
     ],
diff --git a/tests/sources/pip_build.py b/tests/sources/pip_build.py
index 35333c9..27084d9 100644
--- a/tests/sources/pip_build.py
+++ b/tests/sources/pip_build.py
@@ -49,11 +49,16 @@ def test_pip_source_import_packages(cli, datafiles, setup_pypi_repo):
         "kind": "import",
         "sources": [
             {"kind": "local", "path": "files/pip-source"},
-            {"kind": "pip", "url": "file://{}".format(os.path.realpath(pypi_repo)), "packages": [myreqs_packages],},
+            {
+                "kind": "pip",
+                "url": "file://{}".format(os.path.realpath(pypi_repo)),
+                "packages": [myreqs_packages],
+            },
         ],
     }
     os.makedirs(
-        os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True,
+        os.path.dirname(os.path.join(element_path, element_name)),
+        exist_ok=True,
     )
     _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
 
@@ -63,7 +68,10 @@ def test_pip_source_import_packages(cli, datafiles, setup_pypi_repo):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(
@@ -119,7 +127,8 @@ def test_pip_source_import_requirements_files(cli, datafiles, setup_pypi_repo):
         ],
     }
     os.makedirs(
-        os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True,
+        os.path.dirname(os.path.join(element_path, element_name)),
+        exist_ok=True,
     )
     _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
 
@@ -129,7 +138,10 @@ def test_pip_source_import_requirements_files(cli, datafiles, setup_pypi_repo):
     result = cli.run(project=project, args=["build", element_name])
     assert result.exit_code == 0
 
-    result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+    result = cli.run(
+        project=project,
+        args=["artifact", "checkout", element_name, "--directory", checkout],
+    )
     assert result.exit_code == 0
 
     assert_contains(
@@ -193,7 +205,8 @@ def test_pip_source_build(cli, datafiles, setup_pypi_repo):
         },
     }
     os.makedirs(
-        os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True,
+        os.path.dirname(os.path.join(element_path, element_name)),
+        exist_ok=True,
     )
     _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
 
diff --git a/tests/testutils/python_repo.py b/tests/testutils/python_repo.py
index 52dd8a6..870de0c 100644
--- a/tests/testutils/python_repo.py
+++ b/tests/testutils/python_repo.py
@@ -76,7 +76,14 @@ def generate_pip_package(tmpdir, pypi, name, version="0.1", dependencies=None):
     setup_file = os.path.join(tmpdir, "setup.py")
     pkgdirname = re.sub("[^0-9a-zA-Z]+", "", name)
     with open(setup_file, "w", encoding="utf-8") as f:
-        f.write(SETUP_TEMPLATE.format(name=name, version=version, pkgdirname=pkgdirname, pkgdeps=dependencies,))
+        f.write(
+            SETUP_TEMPLATE.format(
+                name=name,
+                version=version,
+                pkgdirname=pkgdirname,
+                pkgdeps=dependencies,
+            )
+        )
     os.chmod(setup_file, 0o755)
 
     package = os.path.join(tmpdir, pkgdirname)
@@ -124,7 +131,10 @@ def setup_pypi_repo(tmpdir):
         for package, dependencies in packages.items():
             pkgdir = create_pkgdir(package)
             generate_pip_package(
-                pkgdir, pypi_repo, package, dependencies=list(dependencies.keys()),
+                pkgdir,
+                pypi_repo,
+                package,
+                dependencies=list(dependencies.keys()),
             )
             for dependency, dependency_dependencies in dependencies.items():
                 add_packages({dependency: dependency_dependencies}, pypi_repo)
diff --git a/tests/testutils/repo/bzrrepo.py b/tests/testutils/repo/bzrrepo.py
index 324244c..506dff1 100644
--- a/tests/testutils/repo/bzrrepo.py
+++ b/tests/testutils/repo/bzrrepo.py
@@ -30,7 +30,9 @@ class Bzr(Repo):
         self.copy_directory(directory, branch_dir)
         subprocess.call([self.bzr, "add", "."], env=self.env, cwd=branch_dir)
         subprocess.call(
-            [self.bzr, "commit", '--message="Initial commit"'], env=self.env, cwd=branch_dir,
+            [self.bzr, "commit", '--message="Initial commit"'],
+            env=self.env,
+            cwd=branch_dir,
         )
 
         return self.latest_commit()
@@ -48,7 +50,13 @@ class Bzr(Repo):
 
     def latest_commit(self):
         return subprocess.check_output(
-            [self.bzr, "version-info", "--custom", "--template={revno}", os.path.join(self.repo, "trunk"),],
+            [
+                self.bzr,
+                "version-info",
+                "--custom",
+                "--template={revno}",
+                os.path.join(self.repo, "trunk"),
+            ],
             env=self.env,
             universal_newlines=True,
         ).strip()
diff --git a/tests/testutils/repo/gitrepo.py b/tests/testutils/repo/gitrepo.py
index 9cb3c9a..a4bf6e4 100644
--- a/tests/testutils/repo/gitrepo.py
+++ b/tests/testutils/repo/gitrepo.py
@@ -95,7 +95,12 @@ class Git(Repo):
         return config
 
     def latest_commit(self):
-        return self._run_git("rev-parse", "HEAD", stdout=subprocess.PIPE, universal_newlines=True,).stdout.strip()
+        return self._run_git(
+            "rev-parse",
+            "HEAD",
+            stdout=subprocess.PIPE,
+            universal_newlines=True,
+        ).stdout.strip()
 
     def branch(self, branch_name):
         self._run_git("checkout", "-b", branch_name)
@@ -111,4 +116,9 @@ class Git(Repo):
         return self.latest_commit()
 
     def rev_parse(self, rev):
-        return self._run_git("rev-parse", rev, stdout=subprocess.PIPE, universal_newlines=True,).stdout.strip()
+        return self._run_git(
+            "rev-parse",
+            rev,
+            stdout=subprocess.PIPE,
+            universal_newlines=True,
+        ).stdout.strip()
diff --git a/tox.ini b/tox.ini
index 840c174..4a3f1ff 100644
--- a/tox.ini
+++ b/tox.ini
@@ -57,7 +57,7 @@ whitelist_externals =
 [testenv:format]
 skip_install = True
 deps =
-    black==19.10b0
+    black==22.3.0
 commands =
     black {posargs: src tests setup.py}
 
@@ -67,7 +67,7 @@ commands =
 [testenv:format-check]
 skip_install = True
 deps =
-    black==19.10b0
+    black==22.3.0
 commands =
     black --check --diff {posargs: src tests setup.py}