You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:37:38 UTC

[buildstream] 01/01: setup.cfg: Use isort to sort our imports

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

root pushed a commit to branch bschubert/isort
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 2833a6abd562a628f4039e74a1dadf12661d2b6d
Author: Benjamin Schubert <co...@benschubert.me>
AuthorDate: Fri Jul 3 11:33:17 2020 +0100

    setup.cfg: Use isort to sort our imports
---
 .pylintrc                                          |  5 +++
 doc/source/conf.py                                 |  1 +
 setup.cfg                                          | 10 ++++++
 setup.py                                           |  4 +--
 src/buildstream/_artifact.py                       |  5 ++-
 src/buildstream/_artifactcache.py                  |  8 ++---
 src/buildstream/_artifactelement.py                |  3 +-
 src/buildstream/_basecache.py                      |  6 ++--
 src/buildstream/_cachekey.py                       |  1 -
 src/buildstream/_cas/cascache.py                   | 16 ++++-----
 src/buildstream/_cas/casdprocessmanager.py         |  9 +++--
 src/buildstream/_cas/casremote.py                  |  5 ++-
 src/buildstream/_cas/casserver.py                  | 21 +++++-------
 src/buildstream/_context.py                        | 17 +++++-----
 src/buildstream/_frontend/__init__.py              |  1 +
 src/buildstream/_frontend/app.py                   | 17 ++++------
 src/buildstream/_frontend/cli.py                   | 10 +++---
 src/buildstream/_frontend/complete.py              |  2 +-
 src/buildstream/_frontend/linuxapp.py              |  1 +
 src/buildstream/_frontend/profile.py               |  3 +-
 src/buildstream/_frontend/status.py                |  3 +-
 src/buildstream/_frontend/widget.py                | 11 +++---
 src/buildstream/_gitsourcebase.py                  | 10 +++---
 src/buildstream/_includes.py                       |  3 +-
 src/buildstream/_loader/__init__.py                |  4 +--
 src/buildstream/_loader/loader.py                  | 17 +++++-----
 src/buildstream/_messenger.py                      |  6 ++--
 src/buildstream/_options/optionarch.py             |  2 +-
 src/buildstream/_options/optionbool.py             |  2 +-
 src/buildstream/_options/optionenum.py             |  2 +-
 src/buildstream/_options/optionflags.py            |  2 +-
 src/buildstream/_options/optionos.py               |  1 +
 src/buildstream/_options/optionpool.py             |  5 ++-
 src/buildstream/_pipeline.py                       |  8 ++---
 src/buildstream/_platform/platform.py              |  4 +--
 src/buildstream/_pluginfactory/__init__.py         |  4 +--
 src/buildstream/_pluginfactory/pluginfactory.py    | 17 +++++-----
 src/buildstream/_pluginfactory/pluginorigin.py     |  4 +--
 .../_pluginfactory/pluginoriginjunction.py         |  3 +-
 src/buildstream/_pluginfactory/pluginoriginpip.py  |  3 +-
 src/buildstream/_pluginfactory/sourcefactory.py    |  1 +
 src/buildstream/_profile.py                        |  5 +--
 src/buildstream/_project.py                        | 29 ++++++++--------
 src/buildstream/_projectrefs.py                    |  2 +-
 .../_protos/buildstream/v2/artifact_pb2.py         |  8 +++--
 .../_protos/buildstream/v2/buildstream_pb2.py      |  8 +++--
 .../_protos/buildstream/v2/source_pb2.py           |  8 +++--
 .../_protos/google/api/annotations_pb2.py          |  6 ++--
 .../_protos/google/api/annotations_pb2_grpc.py     |  1 -
 src/buildstream/_protos/google/api/http_pb2.py     |  1 +
 .../_protos/google/api/http_pb2_grpc.py            |  1 -
 .../_protos/google/bytestream/bytestream_pb2.py    |  6 ++--
 .../_protos/google/longrunning/operations_pb2.py   | 10 +++---
 .../google/longrunning/operations_pb2_grpc.py      |  2 +-
 src/buildstream/_protos/google/rpc/code_pb2.py     |  3 +-
 .../_protos/google/rpc/code_pb2_grpc.py            |  1 -
 src/buildstream/_protos/google/rpc/status_pb2.py   |  3 +-
 .../_protos/google/rpc/status_pb2_grpc.py          |  1 -
 src/buildstream/_remote.py                         |  2 +-
 src/buildstream/_scheduler/__init__.py             | 12 +++----
 src/buildstream/_scheduler/jobs/elementjob.py      |  3 +-
 src/buildstream/_scheduler/jobs/job.py             |  4 +--
 .../_scheduler/queues/artifactpushqueue.py         |  4 +--
 src/buildstream/_scheduler/queues/buildqueue.py    |  4 +--
 src/buildstream/_scheduler/queues/fetchqueue.py    |  4 +--
 src/buildstream/_scheduler/queues/pullqueue.py     |  6 ++--
 src/buildstream/_scheduler/queues/queue.py         | 11 +++---
 .../_scheduler/queues/sourcepushqueue.py           |  4 +--
 src/buildstream/_scheduler/queues/trackqueue.py    |  5 ++-
 src/buildstream/_scheduler/scheduler.py            | 17 +++++-----
 src/buildstream/_signals.py                        |  3 +-
 src/buildstream/_sourcecache.py                    | 11 +++---
 src/buildstream/_stream.py                         | 39 +++++++++++-----------
 src/buildstream/_workspaces.py                     |  4 +--
 src/buildstream/buildelement.py                    |  1 -
 src/buildstream/downloadablefilesource.py          | 10 +++---
 src/buildstream/element.py                         | 29 +++++++---------
 src/buildstream/plugin.py                          |  4 +--
 src/buildstream/plugins/elements/compose.py        |  1 +
 src/buildstream/plugins/elements/import.py         |  1 +
 src/buildstream/plugins/sources/bzr.py             |  5 ++-
 src/buildstream/plugins/sources/local.py           |  3 +-
 src/buildstream/plugins/sources/patch.py           |  4 +--
 src/buildstream/plugins/sources/remote.py          |  1 +
 src/buildstream/plugins/sources/tar.py             |  3 +-
 src/buildstream/plugins/sources/workspace.py       |  4 +--
 src/buildstream/plugins/sources/zip.py             |  5 ++-
 src/buildstream/sandbox/__init__.py                |  4 +--
 src/buildstream/sandbox/_sandboxbuildboxrun.py     |  4 +--
 src/buildstream/sandbox/_sandboxreapi.py           |  2 +-
 src/buildstream/sandbox/_sandboxremote.py          | 16 ++++-----
 src/buildstream/sandbox/sandbox.py                 |  8 ++---
 src/buildstream/scriptelement.py                   |  2 +-
 src/buildstream/source.py                          | 17 +++++-----
 src/buildstream/storage/__init__.py                |  2 +-
 src/buildstream/storage/_casbaseddirectory.py      |  5 +--
 src/buildstream/storage/_filebaseddirectory.py     | 15 ++++++---
 src/buildstream/storage/directory.py               |  2 +-
 src/buildstream/testing/__init__.py                | 10 +++---
 src/buildstream/testing/_fixtures.py               |  1 +
 .../testing/_sourcetests/build_checkout.py         |  6 ++--
 src/buildstream/testing/_sourcetests/conftest.py   |  3 +-
 src/buildstream/testing/_sourcetests/fetch.py      |  9 ++---
 src/buildstream/testing/_sourcetests/mirror.py     |  6 ++--
 .../testing/_sourcetests/source_determinism.py     |  6 ++--
 src/buildstream/testing/_sourcetests/track.py      |  9 ++---
 .../testing/_sourcetests/track_cross_junction.py   |  6 ++--
 src/buildstream/testing/_sourcetests/utils.py      |  7 ++--
 src/buildstream/testing/_sourcetests/workspace.py  |  4 ++-
 src/buildstream/testing/_update_cachekeys.py       |  2 +-
 src/buildstream/testing/_utils/junction.py         |  4 ++-
 src/buildstream/testing/_utils/site.py             |  3 +-
 src/buildstream/testing/runcli.py                  | 19 +++++------
 src/buildstream/utils.py                           | 15 ++++-----
 tests/artifactcache/artifactservice.py             |  4 +--
 tests/artifactcache/capabilities.py                |  5 ++-
 tests/artifactcache/config.py                      |  8 ++---
 tests/artifactcache/expiry.py                      |  1 -
 tests/artifactcache/junctions.py                   |  4 +--
 tests/artifactcache/pull.py                        |  1 -
 tests/artifactcache/push.py                        |  3 +-
 tests/cachekey/cachekey.py                         | 11 +++---
 tests/conftest.py                                  |  4 +--
 tests/elements/filter.py                           |  6 ++--
 tests/examples/autotools.py                        |  3 +-
 tests/examples/developing.py                       |  4 ++-
 tests/examples/first-project.py                    |  4 +--
 tests/examples/flatpak-autotools.py                |  4 +--
 tests/examples/integration-commands.py             |  4 +--
 tests/examples/junctions.py                        |  3 +-
 tests/examples/running-commands.py                 |  4 +--
 tests/format/assertion.py                          |  2 ++
 tests/format/dependencies.py                       |  1 +
 tests/format/include.py                            |  4 ++-
 tests/format/include_composition.py                |  5 ++-
 tests/format/invalid_keys.py                       |  2 ++
 tests/format/junctions.py                          |  1 -
 tests/format/link.py                               |  3 +-
 tests/format/listdirectiveerrors.py                |  2 ++
 tests/format/option-list-directive.py              |  2 ++
 tests/format/optionbool.py                         |  2 ++
 tests/format/optioneltmask.py                      |  2 ++
 tests/format/optionenum.py                         |  2 ++
 tests/format/optionexports.py                      |  2 ++
 tests/format/optionflags.py                        |  2 ++
 tests/format/optionoverrides.py                    |  2 ++
 tests/format/options.py                            |  2 ++
 tests/format/project.py                            |  3 +-
 tests/format/projectoverrides.py                   |  2 ++
 tests/format/substitutions.py                      |  3 +-
 tests/format/variables.py                          |  1 -
 tests/frontend/__init__.py                         |  1 +
 tests/frontend/artifact_delete.py                  |  3 +-
 tests/frontend/artifact_list_contents.py           |  2 +-
 tests/frontend/artifact_log.py                     |  2 +-
 tests/frontend/artifact_show.py                    |  3 +-
 tests/frontend/buildcheckout.py                    | 13 ++++----
 tests/frontend/completions.py                      |  2 ++
 tests/frontend/compose_splits.py                   |  2 ++
 tests/frontend/configurable_warnings.py            |  4 +--
 tests/frontend/cross_junction_workspace.py         |  3 +-
 tests/frontend/default_target.py                   |  1 +
 tests/frontend/fetch.py                            |  5 +--
 tests/frontend/help.py                             |  1 +
 tests/frontend/init.py                             |  6 ++--
 tests/frontend/interactive_init.py                 |  4 +--
 tests/frontend/large_directory.py                  |  6 ++--
 tests/frontend/logging.py                          |  3 +-
 tests/frontend/mirror.py                           |  4 +--
 tests/frontend/order.py                            |  5 +--
 tests/frontend/overlaps.py                         |  7 ++--
 tests/frontend/progress.py                         |  3 +-
 tests/frontend/pull.py                             | 10 +++---
 tests/frontend/push.py                             |  7 ++--
 tests/frontend/rebuild.py                          |  2 ++
 tests/frontend/remote-caches.py                    |  3 +-
 tests/frontend/show.py                             |  8 +++--
 tests/frontend/source_checkout.py                  |  3 +-
 tests/frontend/track.py                            | 11 +++---
 tests/frontend/version.py                          |  4 +--
 tests/frontend/workspace.py                        |  8 ++---
 tests/integration/artifact.py                      |  1 -
 tests/integration/autotools.py                     |  4 +--
 tests/integration/build-uid.py                     |  4 +--
 tests/integration/cachedfail.py                    |  4 +--
 tests/integration/compose-symlinks.py              |  2 +-
 tests/integration/compose.py                       |  5 ++-
 tests/integration/filter.py                        |  4 +--
 tests/integration/import.py                        |  3 +-
 tests/integration/interactive_build.py             |  3 +-
 tests/integration/manual.py                        |  3 +-
 tests/integration/messages.py                      |  2 +-
 tests/integration/pip_source.py                    |  5 ++-
 tests/integration/pullbuildtrees.py                |  6 ++--
 tests/integration/sandbox.py                       |  2 +-
 tests/integration/script.py                        |  4 +--
 tests/integration/shell.py                         |  8 ++---
 tests/integration/shellbuildtrees.py               |  3 +-
 tests/integration/sockets.py                       |  2 +-
 tests/integration/source-determinism.py            |  4 +--
 tests/integration/stack.py                         |  2 +-
 tests/integration/symlinks.py                      |  2 +-
 tests/integration/workspace.py                     |  4 +--
 tests/internals/context.py                         |  3 +-
 tests/internals/loader.py                          |  8 ++---
 tests/internals/pluginloading.py                   |  5 +--
 tests/internals/storage.py                         |  8 ++---
 tests/internals/storage_vdir_import.py             |  7 ++--
 tests/internals/utils_move_atomic.py               |  4 +--
 tests/internals/utils_save_atomic.py               |  1 +
 tests/internals/yaml.py                            |  5 ++-
 tests/plugins/loading.py                           |  4 +--
 tests/plugins/sample-plugins/setup.py              |  2 +-
 tests/remoteexecution/buildfail.py                 |  3 +-
 tests/remoteexecution/buildtree.py                 |  1 +
 tests/remoteexecution/junction.py                  |  5 ++-
 tests/remoteexecution/partial.py                   |  2 +-
 tests/remoteexecution/simple.py                    |  2 +-
 tests/remoteexecution/workspace.py                 |  1 +
 tests/sandboxes/missing-command.py                 |  3 +-
 tests/sandboxes/missing_dependencies.py            |  5 ++-
 tests/sandboxes/selection.py                       |  3 +-
 tests/sourcecache/cache.py                         |  3 +-
 tests/sourcecache/capabilities.py                  |  5 ++-
 tests/sourcecache/config.py                        |  2 +-
 tests/sourcecache/fetch.py                         |  7 ++--
 .../project/plugins/elements/always_fail.py        |  2 +-
 tests/sourcecache/push.py                          |  7 ++--
 tests/sourcecache/staging.py                       |  3 +-
 tests/sourcecache/workspace.py                     |  1 -
 tests/sources/bzr.py                               |  4 +--
 tests/sources/git.py                               |  5 ++-
 tests/sources/keytest.py                           |  3 +-
 tests/sources/local.py                             |  2 ++
 tests/sources/no_fetch_cached.py                   |  4 +--
 tests/sources/patch.py                             |  2 ++
 tests/sources/pip.py                               |  1 +
 tests/sources/previous_source_access.py            |  3 +-
 .../plugins/sources/foo_transform.py               |  2 +-
 tests/sources/remote.py                            |  5 +--
 tests/sources/tar.py                               |  6 ++--
 tests/sources/variables.py                         |  1 -
 tests/sources/zip.py                               |  4 ++-
 tests/testutils/__init__.py                        |  6 ++--
 tests/testutils/artifactshare.py                   |  2 +-
 tests/testutils/context.py                         |  3 +-
 tests/testutils/element_generators.py              |  3 +-
 tests/testutils/http_server.py                     |  6 ++--
 tests/testutils/platform.py                        |  2 +-
 tests/testutils/python_repo.py                     |  1 -
 tests/testutils/repo/bzr.py                        |  1 +
 tests/testutils/repo/tar.py                        |  3 +-
 tests/testutils/repo/zip.py                        |  3 +-
 tests/testutils/setuptools.py                      |  3 +-
 tox.ini                                            |  6 +++-
 255 files changed, 664 insertions(+), 593 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 25d5647..397b293 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -125,6 +125,11 @@ disable=#####################################
         line-too-long,
         superfluous-parens,
 
+        ##################################################
+        # Formatting-related messages, enforced by isort #
+        ##################################################
+
+        wrong-import-position,
 
 # Enable the message, report, category or checker with the given id(s). You can
 # either give multiple identifier separated by comma (,) or put this option
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 0234d39..091bb95 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -19,6 +19,7 @@
 #
 import os
 import sys
+
 from buildstream import __version__
 
 sys.path.insert(0, os.path.abspath(".."))
diff --git a/setup.cfg b/setup.cfg
index 5a3a75d..c6ea8ba 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -20,6 +20,16 @@ markers =
     remoteexecution: run test only if --remote-execution option is specified
 xfail_strict=True
 
+[tool:isort]
+line_length = 119
+multi_line_output = 3
+include_trailing_comma = true
+use_parentheses = true
+default_section: THIRDPARTY
+known_first_party = buildstream
+known_tests = tests
+sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,TESTS,LOCALFOLDER
+
 [mypy]
 files = src
 warn_unused_configs = True
diff --git a/setup.py b/setup.py
index c300d33..f09539f 100755
--- a/setup.py
+++ b/setup.py
@@ -20,13 +20,13 @@
 #        Benjamin Schubert <bs...@bloomberg.net>
 
 import os
-from pathlib import Path
 import re
 import sys
+from pathlib import Path
 
 # Add local directory to the path, in order to be able to import versioneer
 sys.path.append(os.path.dirname(__file__))
-import versioneer  # pylint: disable=wrong-import-position
+import versioneer  # isort:skip
 
 
 ##################################################################
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index cf82a16..28dfaa4 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -30,12 +30,11 @@ artifact composite interaction away from Element class
 
 import os
 
+from . import _yaml, utils
 from ._exceptions import ArtifactError
 from ._protos.buildstream.v2.artifact_pb2 import Artifact as ArtifactProto
-from . import _yaml
-from . import utils
-from .types import Scope
 from .storage._casbaseddirectory import CasBasedDirectory
+from .types import Scope
 
 
 # An Artifact class to abstract artifact operations
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py
index 46fc5fb..b7bd824 100644
--- a/src/buildstream/_artifactcache.py
+++ b/src/buildstream/_artifactcache.py
@@ -19,15 +19,15 @@
 #        Tristan Maat <tr...@codethink.co.uk>
 
 import os
+
 import grpc
 
+from . import utils
 from ._basecache import BaseCache
 from ._cas.casremote import BlobNotFound
-from ._exceptions import ArtifactError, CASError, CacheError, CASRemoteError, RemoteError
-from ._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc, artifact_pb2, artifact_pb2_grpc
-
+from ._exceptions import ArtifactError, CacheError, CASError, CASRemoteError, RemoteError
+from ._protos.buildstream.v2 import artifact_pb2, artifact_pb2_grpc, buildstream_pb2, buildstream_pb2_grpc
 from ._remote import BaseRemote
-from . import utils
 
 
 # ArtifactRemote():
diff --git a/src/buildstream/_artifactelement.py b/src/buildstream/_artifactelement.py
index 4066cef..ad42cba 100644
--- a/src/buildstream/_artifactelement.py
+++ b/src/buildstream/_artifactelement.py
@@ -19,8 +19,7 @@
 
 from typing import TYPE_CHECKING
 
-from . import Element
-from . import _cachekey
+from . import Element, _cachekey
 from ._exceptions import ArtifactElementError
 from ._loader.metaelement import MetaElement
 from .types import Scope
diff --git a/src/buildstream/_basecache.py b/src/buildstream/_basecache.py
index 91eae6a..d4166df 100644
--- a/src/buildstream/_basecache.py
+++ b/src/buildstream/_basecache.py
@@ -21,14 +21,12 @@ from fnmatch import fnmatch
 from itertools import chain
 from typing import TYPE_CHECKING
 
-from . import utils
-from . import _yaml
+from . import _yaml, utils
 from ._cas import CASRemote
+from ._exceptions import CacheError, LoadError, RemoteError
 from ._message import Message, MessageType
-from ._exceptions import LoadError, RemoteError, CacheError
 from ._remote import RemoteSpec, RemoteType
 
-
 if TYPE_CHECKING:
     from typing import Optional, Type
     from ._exceptions import BstError
diff --git a/src/buildstream/_cachekey.py b/src/buildstream/_cachekey.py
index dd92075..5bf11e5 100644
--- a/src/buildstream/_cachekey.py
+++ b/src/buildstream/_cachekey.py
@@ -22,7 +22,6 @@ import hashlib
 
 import ujson
 
-
 # Internal record of the size of a cache key
 _CACHEKEY_SIZE = len(hashlib.sha256().hexdigest())
 
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 7936121..a5757f1 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -18,26 +18,24 @@
 #  Authors:
 #        Jürg Billeter <ju...@codethink.co.uk>
 
-import itertools
-import os
-import stat
 import contextlib
 import ctypes
+import itertools
 import multiprocessing
+import os
 import signal
+import stat
 import time
-from typing import Optional, List
+from typing import List, Optional
 
 import grpc
 
-from .._protos.google.rpc import code_pb2
+from .. import _signals, utils
+from .._exceptions import CASCacheError
 from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
 from .._protos.build.buildgrid import local_cas_pb2
-
-from .. import _signals, utils
+from .._protos.google.rpc import code_pb2
 from ..types import FastEnum, SourceRef
-from .._exceptions import CASCacheError
-
 from .casdprocessmanager import CASDProcessManager
 from .casremote import _CASBatchRead, _CASBatchUpdate
 
diff --git a/src/buildstream/_cas/casdprocessmanager.py b/src/buildstream/_cas/casdprocessmanager.py
index 637c4e0..55121b4 100644
--- a/src/buildstream/_cas/casdprocessmanager.py
+++ b/src/buildstream/_cas/casdprocessmanager.py
@@ -25,17 +25,16 @@ import stat
 import subprocess
 import tempfile
 import time
-import psutil
 
 import grpc
-
-from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2_grpc
-from .._protos.build.buildgrid import local_cas_pb2_grpc
-from .._protos.google.bytestream import bytestream_pb2_grpc
+import psutil
 
 from .. import _signals, utils
 from .._exceptions import CASCacheError
 from .._message import Message, MessageType
+from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2_grpc
+from .._protos.build.buildgrid import local_cas_pb2_grpc
+from .._protos.google.bytestream import bytestream_pb2_grpc
 
 _CASD_MAX_LOGFILES = 10
 _CASD_TIMEOUT = 300  # in seconds
diff --git a/src/buildstream/_cas/casremote.py b/src/buildstream/_cas/casremote.py
index 93f4e50..16a5d8d 100644
--- a/src/buildstream/_cas/casremote.py
+++ b/src/buildstream/_cas/casremote.py
@@ -15,11 +15,10 @@
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 #
 
-from .._protos.google.rpc import code_pb2
+from .._exceptions import CASRemoteError
 from .._protos.build.buildgrid import local_cas_pb2
-
+from .._protos.google.rpc import code_pb2
 from .._remote import BaseRemote
-from .._exceptions import CASRemoteError
 
 # The default limit for gRPC messages is 4 MiB.
 # Limit payload to 1 MiB to leave sufficient headroom for metadata.
diff --git a/src/buildstream/_cas/casserver.py b/src/buildstream/_cas/casserver.py
index 71d7d90..c90a98c 100644
--- a/src/buildstream/_cas/casserver.py
+++ b/src/buildstream/_cas/casserver.py
@@ -17,33 +17,29 @@
 #  Authors:
 #        Jürg Billeter <ju...@codethink.co.uk>
 
-from concurrent import futures
-from enum import Enum
 import contextlib
 import logging
 import os
 import signal
 import sys
+from concurrent import futures
+from enum import Enum
 
+import click
 import grpc
 from google.protobuf.message import DecodeError
-import click
 
-from .._protos.build.bazel.remote.execution.v2 import (
-    remote_execution_pb2,
-    remote_execution_pb2_grpc,
-)
-from .._protos.google.bytestream import bytestream_pb2_grpc
+from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc
 from .._protos.build.buildgrid import local_cas_pb2
 from .._protos.buildstream.v2 import (
-    buildstream_pb2,
-    buildstream_pb2_grpc,
     artifact_pb2,
     artifact_pb2_grpc,
+    buildstream_pb2,
+    buildstream_pb2_grpc,
     source_pb2,
     source_pb2_grpc,
 )
-
+from .._protos.google.bytestream import bytestream_pb2_grpc
 # Note: We'd ideally like to avoid imports from the core codebase as
 # much as possible, since we're expecting to eventually split this
 # module off into its own project.
@@ -51,10 +47,9 @@ from .._protos.buildstream.v2 import (
 # Not enough that we'd like to duplicate code, but enough that we want
 # to make it very obvious what we're using, so in this case we import
 # the specific methods we'll be using.
-from ..utils import save_file_atomic, _remove_path_with_parents
+from ..utils import _remove_path_with_parents, save_file_atomic
 from .casdprocessmanager import CASDProcessManager
 
-
 # The default limit for gRPC messages is 4 MiB.
 # Limit payload to 1 MiB to leave sufficient headroom for metadata.
 _MAX_PAYLOAD_BYTES = 1024 * 1024
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index c0e92b9..6f7629e 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -19,21 +19,20 @@
 
 import os
 import shutil
-from . import utils
-from . import _site
-from . import _yaml
+
+from . import _site, _yaml, utils
+from ._artifactcache import ArtifactCache
+from ._cas import CASCache, CASLogLevel
 from ._exceptions import LoadError
-from .exceptions import LoadErrorReason
 from ._messenger import Messenger
-from ._profile import Topics, PROFILER
 from ._platform import Platform
-from ._artifactcache import ArtifactCache
+from ._profile import PROFILER, Topics
 from ._sourcecache import SourceCache
-from ._cas import CASCache, CASLogLevel
-from .types import _CacheBuildTrees, _PipelineSelection, _SchedulerErrorAction
-from ._workspaces import Workspaces, WorkspaceProjectCache
+from ._workspaces import WorkspaceProjectCache, Workspaces
+from .exceptions import LoadErrorReason
 from .node import Node
 from .sandbox import SandboxRemote
+from .types import _CacheBuildTrees, _PipelineSelection, _SchedulerErrorAction
 
 
 # Context()
diff --git a/src/buildstream/_frontend/__init__.py b/src/buildstream/_frontend/__init__.py
index febd497..0744b81 100644
--- a/src/buildstream/_frontend/__init__.py
+++ b/src/buildstream/_frontend/__init__.py
@@ -17,6 +17,7 @@
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 import os
+
 from .cli import cli
 
 if "_BST_COMPLETION" not in os.environ:
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py
index b77cfc1..df840de 100644
--- a/src/buildstream/_frontend/app.py
+++ b/src/buildstream/_frontend/app.py
@@ -17,30 +17,27 @@
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 
-from contextlib import contextmanager
+import datetime
 import os
 import sys
 import traceback
-import datetime
+from contextlib import contextmanager
 from textwrap import TextWrapper
+
 import click
 from click import UsageError
 
 # Import buildstream public symbols
-from .. import Scope
-
+from .. import Scope, node, utils
 # Import various buildstream internals
 from .._context import Context
-from .._project import Project
-from .._exceptions import BstError, StreamError, LoadError, AppError
-from ..exceptions import LoadErrorReason
+from .._exceptions import AppError, BstError, LoadError, StreamError
 from .._message import Message, MessageType, unconditional_messages
+from .._project import Project
 from .._stream import Stream
+from ..exceptions import LoadErrorReason
 from ..types import _SchedulerErrorAction
-from .. import node
-from .. import utils
 from ..utils import UtilError
-
 # Import frontend assets
 from .profile import Profile
 from .status import Status
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index d5fa470..26dc6ec 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1,15 +1,15 @@
 import os
+import shutil
 import sys
 from functools import partial
 
-import shutil
 import click
+
 from .. import _yaml
-from .._exceptions import BstError, LoadError, AppError
-from .complete import main_bashcomplete, complete_path, CompleteUnhandled
-from ..types import _CacheBuildTrees, _SchedulerErrorAction, _PipelineSelection
+from .._exceptions import AppError, BstError, LoadError
+from ..types import _CacheBuildTrees, _PipelineSelection, _SchedulerErrorAction
 from ..utils import UtilError
-
+from .complete import CompleteUnhandled, complete_path, main_bashcomplete
 
 ##################################################################
 #              Helper classes and methods for Click              #
diff --git a/src/buildstream/_frontend/complete.py b/src/buildstream/_frontend/complete.py
index 45e857e..4afd75c 100644
--- a/src/buildstream/_frontend/complete.py
+++ b/src/buildstream/_frontend/complete.py
@@ -36,7 +36,7 @@ import copy
 import os
 
 import click
-from click.core import MultiCommand, Option, Argument
+from click.core import Argument, MultiCommand, Option
 from click.parser import split_arg_string
 
 WORDBREAK = "="
diff --git a/src/buildstream/_frontend/linuxapp.py b/src/buildstream/_frontend/linuxapp.py
index 987b023..2cb8e2e 100644
--- a/src/buildstream/_frontend/linuxapp.py
+++ b/src/buildstream/_frontend/linuxapp.py
@@ -17,6 +17,7 @@
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 import os
+
 import click
 
 from .app import App
diff --git a/src/buildstream/_frontend/profile.py b/src/buildstream/_frontend/profile.py
index 02b601c..b5e41cc 100644
--- a/src/buildstream/_frontend/profile.py
+++ b/src/buildstream/_frontend/profile.py
@@ -16,8 +16,9 @@
 #
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
-import re
 import copy
+import re
+
 import click
 
 
diff --git a/src/buildstream/_frontend/status.py b/src/buildstream/_frontend/status.py
index a3f0d8a..953f72b 100644
--- a/src/buildstream/_frontend/status.py
+++ b/src/buildstream/_frontend/status.py
@@ -16,10 +16,11 @@
 #
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
+import curses
 import os
 import sys
-import curses
 from collections import OrderedDict
+
 import click
 
 # Import a widget internal for formatting time codes
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index f07e3db..2f18aeb 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -18,20 +18,21 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 import datetime
 import os
-from collections import defaultdict, OrderedDict
-from contextlib import ExitStack
-from mmap import mmap
 import re
 import textwrap
-from ruamel import yaml
+from collections import OrderedDict, defaultdict
+from contextlib import ExitStack
+from mmap import mmap
+
 import click
+from ruamel import yaml
 
-from .profile import Profile
 from .. import Scope
 from .. import __version__ as bst_version
 from .._exceptions import ImplError
 from .._message import MessageType
 from ..storage.directory import _FileType
+from .profile import Profile
 
 # These messages are printed a bit differently
 ERROR_MESSAGES = [MessageType.FAIL, MessageType.ERROR, MessageType.BUG]
diff --git a/src/buildstream/_gitsourcebase.py b/src/buildstream/_gitsourcebase.py
index e3b2466..6f4c04d 100644
--- a/src/buildstream/_gitsourcebase.py
+++ b/src/buildstream/_gitsourcebase.py
@@ -25,16 +25,14 @@
 import os
 import re
 import shutil
+from configparser import RawConfigParser
 from io import StringIO
 from tempfile import TemporaryFile
 
-from configparser import RawConfigParser
-
-from .source import Source, SourceError, SourceFetcher
-from .types import CoreWarnings
 from . import utils
-from .types import FastEnum
-from .utils import move_atomic, DirectoryExistsError
+from .source import Source, SourceError, SourceFetcher
+from .types import CoreWarnings, FastEnum
+from .utils import DirectoryExistsError, move_atomic
 
 GIT_MODULES = ".gitmodules"
 EXACT_TAG_PATTERN = r"(?P<tag>.*)-0-g(?P<commit>.*)"
diff --git a/src/buildstream/_includes.py b/src/buildstream/_includes.py
index 1556bc6..24f7ed8 100644
--- a/src/buildstream/_includes.py
+++ b/src/buildstream/_includes.py
@@ -1,8 +1,9 @@
 import os
+
 from . import _yaml
-from .node import MappingNode, ScalarNode, SequenceNode
 from ._exceptions import LoadError
 from .exceptions import LoadErrorReason
+from .node import MappingNode, ScalarNode, SequenceNode
 
 
 # Includes()
diff --git a/src/buildstream/_loader/__init__.py b/src/buildstream/_loader/__init__.py
index fd5cac2..7980e77 100644
--- a/src/buildstream/_loader/__init__.py
+++ b/src/buildstream/_loader/__init__.py
@@ -17,7 +17,7 @@
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 
-from .metasource import MetaSource
-from .metaelement import MetaElement
 from .loadcontext import LoadContext
 from .loader import Loader
+from .metaelement import MetaElement
+from .metasource import MetaSource
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index 81e5fb0..019aed1 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -20,22 +20,21 @@
 import os
 from contextlib import suppress
 
-from .._exceptions import LoadError
-from ..exceptions import LoadErrorReason
 from .. import _yaml
+from .._exceptions import LoadError
+from .._includes import Includes
+from .._message import Message, MessageType
+from .._profile import PROFILER, Topics
 from ..element import Element
+from ..exceptions import LoadErrorReason
 from ..node import Node
-from .._profile import Topics, PROFILER
-from .._includes import Includes
-
-from ._loader import valid_chars_name
-from .types import Symbol, extract_depends_from_node
+from ..types import CoreWarnings, _KeyStrength
 from . import loadelement
+from ._loader import valid_chars_name
 from .loadelement import Dependency, LoadElement
 from .metaelement import MetaElement
 from .metasource import MetaSource
-from ..types import CoreWarnings, _KeyStrength
-from .._message import Message, MessageType
+from .types import Symbol, extract_depends_from_node
 
 
 # Loader():
diff --git a/src/buildstream/_messenger.py b/src/buildstream/_messenger.py
index 3a32a24..24c9973 100644
--- a/src/buildstream/_messenger.py
+++ b/src/buildstream/_messenger.py
@@ -17,16 +17,14 @@
 #  Authors:
 #        Angelos Evripiotis <je...@bloomberg.net>
 
-import os
 import datetime
+import os
 from contextlib import contextmanager
 
-from . import _signals
-from . import utils
+from . import _signals, utils
 from ._exceptions import BstError
 from ._message import Message, MessageType
 
-
 _RENDER_INTERVAL = datetime.timedelta(seconds=1)
 
 
diff --git a/src/buildstream/_options/optionarch.py b/src/buildstream/_options/optionarch.py
index 651afbe..e3d1355 100644
--- a/src/buildstream/_options/optionarch.py
+++ b/src/buildstream/_options/optionarch.py
@@ -18,8 +18,8 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 
 from .._exceptions import LoadError, PlatformError
-from ..exceptions import LoadErrorReason
 from .._platform import Platform
+from ..exceptions import LoadErrorReason
 from .optionenum import OptionEnum
 
 
diff --git a/src/buildstream/_options/optionbool.py b/src/buildstream/_options/optionbool.py
index 57dbd16..97e8d8e 100644
--- a/src/buildstream/_options/optionbool.py
+++ b/src/buildstream/_options/optionbool.py
@@ -19,7 +19,7 @@
 
 from .._exceptions import LoadError
 from ..exceptions import LoadErrorReason
-from .option import Option, OPTION_SYMBOLS
+from .option import OPTION_SYMBOLS, Option
 
 
 # OptionBool
diff --git a/src/buildstream/_options/optionenum.py b/src/buildstream/_options/optionenum.py
index da3a7dc..24d85ce 100644
--- a/src/buildstream/_options/optionenum.py
+++ b/src/buildstream/_options/optionenum.py
@@ -19,7 +19,7 @@
 
 from .._exceptions import LoadError
 from ..exceptions import LoadErrorReason
-from .option import Option, OPTION_SYMBOLS
+from .option import OPTION_SYMBOLS, Option
 
 
 # OptionEnum
diff --git a/src/buildstream/_options/optionflags.py b/src/buildstream/_options/optionflags.py
index 042ef64..835c1ef 100644
--- a/src/buildstream/_options/optionflags.py
+++ b/src/buildstream/_options/optionflags.py
@@ -19,7 +19,7 @@
 
 from .._exceptions import LoadError
 from ..exceptions import LoadErrorReason
-from .option import Option, OPTION_SYMBOLS
+from .option import OPTION_SYMBOLS, Option
 
 
 # OptionFlags
diff --git a/src/buildstream/_options/optionos.py b/src/buildstream/_options/optionos.py
index 3f4e902..cc1cff2 100644
--- a/src/buildstream/_options/optionos.py
+++ b/src/buildstream/_options/optionos.py
@@ -18,6 +18,7 @@
 #        Raoul Hidalgo Charman <ra...@codethink.co.uk>
 
 import platform
+
 from .optionenum import OptionEnum
 
 
diff --git a/src/buildstream/_options/optionpool.py b/src/buildstream/_options/optionpool.py
index b30d1f0..00c9d34 100644
--- a/src/buildstream/_options/optionpool.py
+++ b/src/buildstream/_options/optionpool.py
@@ -24,14 +24,13 @@ from .._exceptions import LoadError
 from ..exceptions import LoadErrorReason
 from ..node import MappingNode, SequenceNode, _assert_symbol_name
 from ..types import FastEnum
+from .optionarch import OptionArch
 from .optionbool import OptionBool
+from .optioneltmask import OptionEltMask
 from .optionenum import OptionEnum
 from .optionflags import OptionFlags
-from .optioneltmask import OptionEltMask
-from .optionarch import OptionArch
 from .optionos import OptionOS
 
-
 _OPTION_TYPES = {
     OptionBool.OPTION_TYPE: OptionBool,
     OptionEnum.OPTION_TYPE: OptionEnum,
diff --git a/src/buildstream/_pipeline.py b/src/buildstream/_pipeline.py
index 9edc6f5..5afced0 100644
--- a/src/buildstream/_pipeline.py
+++ b/src/buildstream/_pipeline.py
@@ -19,17 +19,17 @@
 #        Jürg Billeter <ju...@codethink.co.uk>
 #        Tristan Maat <tr...@codethink.co.uk>
 
-import os
 import itertools
-from operator import itemgetter
+import os
 from collections import OrderedDict
+from operator import itemgetter
 
 from pyroaring import BitMap  # pylint: disable=no-name-in-module
 
+from . import Scope
 from ._exceptions import PipelineError
 from ._message import Message, MessageType
-from ._profile import Topics, PROFILER
-from . import Scope
+from ._profile import PROFILER, Topics
 from ._project import ProjectRefStorage
 from .types import _PipelineSelection
 
diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py
index 50a1d8e..29b4455 100644
--- a/src/buildstream/_platform/platform.py
+++ b/src/buildstream/_platform/platform.py
@@ -23,9 +23,9 @@ import platform
 
 import psutil
 
-from .._exceptions import PlatformError, ImplError, SandboxError
-from ..sandbox import SandboxDummy
 from .. import utils
+from .._exceptions import ImplError, PlatformError, SandboxError
+from ..sandbox import SandboxDummy
 
 
 class Platform:
diff --git a/src/buildstream/_pluginfactory/__init__.py b/src/buildstream/_pluginfactory/__init__.py
index cd41723..9af2e1d 100644
--- a/src/buildstream/_pluginfactory/__init__.py
+++ b/src/buildstream/_pluginfactory/__init__.py
@@ -15,12 +15,12 @@
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 #
 
+from .elementfactory import ElementFactory
 from .pluginorigin import PluginOrigin, PluginOriginType, PluginType
+from .pluginoriginjunction import PluginOriginJunction
 from .pluginoriginlocal import PluginOriginLocal
 from .pluginoriginpip import PluginOriginPip
-from .pluginoriginjunction import PluginOriginJunction
 from .sourcefactory import SourceFactory
-from .elementfactory import ElementFactory
 
 
 # load_plugin_origin()
diff --git a/src/buildstream/_pluginfactory/pluginfactory.py b/src/buildstream/_pluginfactory/pluginfactory.py
index df950ab..b7171c4 100644
--- a/src/buildstream/_pluginfactory/pluginfactory.py
+++ b/src/buildstream/_pluginfactory/pluginfactory.py
@@ -18,20 +18,19 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 
 import os
-from typing import Tuple, Type, Iterator
+from typing import Iterator, Tuple, Type
+
 from pluginbase import PluginSource
 
-from .. import utils
-from .. import _site
-from ..plugin import Plugin
-from ..source import Source
+from .. import _site, utils
+from .._exceptions import PluginError
+from .._message import Message, MessageType
+from .._messenger import Messenger
 from ..element import Element
 from ..node import ProvenanceInformation
+from ..plugin import Plugin
+from ..source import Source
 from ..utils import UtilError
-from .._exceptions import PluginError
-from .._messenger import Messenger
-from .._message import Message, MessageType
-
 from .pluginorigin import PluginOrigin, PluginType
 
 
diff --git a/src/buildstream/_pluginfactory/pluginorigin.py b/src/buildstream/_pluginfactory/pluginorigin.py
index bd98717..40c4ab5 100644
--- a/src/buildstream/_pluginfactory/pluginorigin.py
+++ b/src/buildstream/_pluginfactory/pluginorigin.py
@@ -15,10 +15,10 @@
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 #
 
-from ..types import FastEnum
-from ..node import ScalarNode, MappingNode
 from .._exceptions import LoadError
 from ..exceptions import LoadErrorReason
+from ..node import MappingNode, ScalarNode
+from ..types import FastEnum
 
 
 # PluginType()
diff --git a/src/buildstream/_pluginfactory/pluginoriginjunction.py b/src/buildstream/_pluginfactory/pluginoriginjunction.py
index 4e0a53c..1ed69cf 100644
--- a/src/buildstream/_pluginfactory/pluginoriginjunction.py
+++ b/src/buildstream/_pluginfactory/pluginoriginjunction.py
@@ -15,8 +15,7 @@
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 #
 from .._exceptions import PluginError
-
-from .pluginorigin import PluginType, PluginOrigin, PluginOriginType
+from .pluginorigin import PluginOrigin, PluginOriginType, PluginType
 
 
 # PluginOriginJunction
diff --git a/src/buildstream/_pluginfactory/pluginoriginpip.py b/src/buildstream/_pluginfactory/pluginoriginpip.py
index 3a9c63f..650cf18 100644
--- a/src/buildstream/_pluginfactory/pluginoriginpip.py
+++ b/src/buildstream/_pluginfactory/pluginoriginpip.py
@@ -17,8 +17,7 @@
 import os
 
 from .._exceptions import PluginError
-
-from .pluginorigin import PluginType, PluginOrigin, PluginOriginType
+from .pluginorigin import PluginOrigin, PluginOriginType, PluginType
 
 
 # PluginOriginPip
diff --git a/src/buildstream/_pluginfactory/sourcefactory.py b/src/buildstream/_pluginfactory/sourcefactory.py
index 2ed78f8..ad08e25 100644
--- a/src/buildstream/_pluginfactory/sourcefactory.py
+++ b/src/buildstream/_pluginfactory/sourcefactory.py
@@ -20,6 +20,7 @@
 from .pluginfactory import PluginFactory
 from .pluginorigin import PluginType
 
+
 # A SourceFactory creates Source instances
 # in the context of a given factory
 #
diff --git a/src/buildstream/_profile.py b/src/buildstream/_profile.py
index 0219e83..55d1250 100644
--- a/src/buildstream/_profile.py
+++ b/src/buildstream/_profile.py
@@ -23,10 +23,11 @@
 
 import contextlib
 import cProfile
-import pstats
-import os
 import datetime
+import os
+import pstats
 import time
+
 from ._exceptions import ProfileError
 
 
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 21dc2b9..fb688c2 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -22,29 +22,28 @@ import os
 import sys
 from collections import OrderedDict
 from pathlib import Path
+
 from pluginbase import PluginBase
-from . import utils
-from . import _site
-from . import _yaml
-from .utils import UtilError
+
+from . import _site, _yaml, utils
+from ._artifactcache import ArtifactCache
 from ._artifactelement import ArtifactElement
-from ._profile import Topics, PROFILER
 from ._exceptions import LoadError
-from .exceptions import LoadErrorReason
+from ._includes import Includes
+from ._loader import LoadContext, Loader
+from ._message import Message, MessageType
 from ._options import OptionPool
-from ._artifactcache import ArtifactCache
+from ._pluginfactory import ElementFactory, SourceFactory, load_plugin_origin
+from ._profile import PROFILER, Topics
+from ._projectrefs import ProjectRefs, ProjectRefStorage
 from ._sourcecache import SourceCache
+from ._workspaces import WORKSPACE_PROJECT_FILE
+from .element import Element
+from .exceptions import LoadErrorReason
 from .node import ScalarNode, SequenceNode, _assert_symbol_name
 from .sandbox import SandboxRemote
-from ._pluginfactory import ElementFactory, SourceFactory, load_plugin_origin
 from .types import CoreWarnings
-from ._projectrefs import ProjectRefs, ProjectRefStorage
-from ._loader import Loader, LoadContext
-from .element import Element
-from ._message import Message, MessageType
-from ._includes import Includes
-from ._workspaces import WORKSPACE_PROJECT_FILE
-
+from .utils import UtilError
 
 # Project Configuration file
 _PROJECT_CONF_FILE = "project.conf"
diff --git a/src/buildstream/_projectrefs.py b/src/buildstream/_projectrefs.py
index 6af4708..e16de28 100644
--- a/src/buildstream/_projectrefs.py
+++ b/src/buildstream/_projectrefs.py
@@ -19,9 +19,9 @@
 import os
 
 from . import _yaml
-from .node import _new_synthetic_file
 from ._exceptions import LoadError
 from .exceptions import LoadErrorReason
+from .node import _new_synthetic_file
 
 
 # ProjectRefStorage()
diff --git a/src/buildstream/_protos/buildstream/v2/artifact_pb2.py b/src/buildstream/_protos/buildstream/v2/artifact_pb2.py
index 8c34ef8..e5955e0 100644
--- a/src/buildstream/_protos/buildstream/v2/artifact_pb2.py
+++ b/src/buildstream/_protos/buildstream/v2/artifact_pb2.py
@@ -6,13 +6,17 @@ from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
+from buildstream._protos.build.bazel.remote.execution.v2 import (
+    remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2,
+)
+from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2
-from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/buildstream/v2/buildstream_pb2.py b/src/buildstream/_protos/buildstream/v2/buildstream_pb2.py
index 0780c9f..7adce4e 100644
--- a/src/buildstream/_protos/buildstream/v2/buildstream_pb2.py
+++ b/src/buildstream/_protos/buildstream/v2/buildstream_pb2.py
@@ -6,13 +6,17 @@ from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
+from buildstream._protos.build.bazel.remote.execution.v2 import (
+    remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2,
+)
+from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2
-from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/buildstream/v2/source_pb2.py b/src/buildstream/_protos/buildstream/v2/source_pb2.py
index 136c4cb..e9ade64 100644
--- a/src/buildstream/_protos/buildstream/v2/source_pb2.py
+++ b/src/buildstream/_protos/buildstream/v2/source_pb2.py
@@ -6,13 +6,17 @@ from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
+from buildstream._protos.build.bazel.remote.execution.v2 import (
+    remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2,
+)
+from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2
-from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/google/api/annotations_pb2.py b/src/buildstream/_protos/google/api/annotations_pb2.py
index 35585c7..3aaa130 100644
--- a/src/buildstream/_protos/google/api/annotations_pb2.py
+++ b/src/buildstream/_protos/google/api/annotations_pb2.py
@@ -3,16 +3,18 @@
 # source: google/api/annotations.proto
 
 from google.protobuf import descriptor as _descriptor
+from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
+from buildstream._protos.google.api import http_pb2 as google_dot_api_dot_http__pb2
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from buildstream._protos.google.api import http_pb2 as google_dot_api_dot_http__pb2
-from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/google/api/annotations_pb2_grpc.py b/src/buildstream/_protos/google/api/annotations_pb2_grpc.py
index a894352..07cb78f 100644
--- a/src/buildstream/_protos/google/api/annotations_pb2_grpc.py
+++ b/src/buildstream/_protos/google/api/annotations_pb2_grpc.py
@@ -1,3 +1,2 @@
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
 import grpc
-
diff --git a/src/buildstream/_protos/google/api/http_pb2.py b/src/buildstream/_protos/google/api/http_pb2.py
index cf4ce32..df98dd8 100644
--- a/src/buildstream/_protos/google/api/http_pb2.py
+++ b/src/buildstream/_protos/google/api/http_pb2.py
@@ -6,6 +6,7 @@ from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
diff --git a/src/buildstream/_protos/google/api/http_pb2_grpc.py b/src/buildstream/_protos/google/api/http_pb2_grpc.py
index a894352..07cb78f 100644
--- a/src/buildstream/_protos/google/api/http_pb2_grpc.py
+++ b/src/buildstream/_protos/google/api/http_pb2_grpc.py
@@ -1,3 +1,2 @@
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
 import grpc
-
diff --git a/src/buildstream/_protos/google/bytestream/bytestream_pb2.py b/src/buildstream/_protos/google/bytestream/bytestream_pb2.py
index d8627d4..893703f 100644
--- a/src/buildstream/_protos/google/bytestream/bytestream_pb2.py
+++ b/src/buildstream/_protos/google/bytestream/bytestream_pb2.py
@@ -6,13 +6,15 @@ from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2
+
+from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
-from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/google/longrunning/operations_pb2.py b/src/buildstream/_protos/google/longrunning/operations_pb2.py
index 7798de3..46faf03 100644
--- a/src/buildstream/_protos/google/longrunning/operations_pb2.py
+++ b/src/buildstream/_protos/google/longrunning/operations_pb2.py
@@ -2,19 +2,21 @@
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: google/longrunning/operations.proto
 
+from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
 from google.protobuf import descriptor as _descriptor
+from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
+from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
+from buildstream._protos.google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
-from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
-from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
-from buildstream._protos.google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/google/longrunning/operations_pb2_grpc.py b/src/buildstream/_protos/google/longrunning/operations_pb2_grpc.py
index 8f89862..c9f4363 100644
--- a/src/buildstream/_protos/google/longrunning/operations_pb2_grpc.py
+++ b/src/buildstream/_protos/google/longrunning/operations_pb2_grpc.py
@@ -1,8 +1,8 @@
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
 import grpc
+from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
 
 from buildstream._protos.google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2
-from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
 
 
 class OperationsStub(object):
diff --git a/src/buildstream/_protos/google/rpc/code_pb2.py b/src/buildstream/_protos/google/rpc/code_pb2.py
index 85a6b2d..1c33cd3 100644
--- a/src/buildstream/_protos/google/rpc/code_pb2.py
+++ b/src/buildstream/_protos/google/rpc/code_pb2.py
@@ -2,11 +2,12 @@
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: google/rpc/code.proto
 
-from google.protobuf.internal import enum_type_wrapper
 from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+from google.protobuf.internal import enum_type_wrapper
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
diff --git a/src/buildstream/_protos/google/rpc/code_pb2_grpc.py b/src/buildstream/_protos/google/rpc/code_pb2_grpc.py
index a894352..07cb78f 100644
--- a/src/buildstream/_protos/google/rpc/code_pb2_grpc.py
+++ b/src/buildstream/_protos/google/rpc/code_pb2_grpc.py
@@ -1,3 +1,2 @@
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
 import grpc
-
diff --git a/src/buildstream/_protos/google/rpc/status_pb2.py b/src/buildstream/_protos/google/rpc/status_pb2.py
index ae0be7d..04d8a81 100644
--- a/src/buildstream/_protos/google/rpc/status_pb2.py
+++ b/src/buildstream/_protos/google/rpc/status_pb2.py
@@ -2,16 +2,17 @@
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: google/rpc/status.proto
 
+from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
 from google.protobuf import descriptor as _descriptor
 from google.protobuf import message as _message
 from google.protobuf import reflection as _reflection
 from google.protobuf import symbol_database as _symbol_database
+
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/src/buildstream/_protos/google/rpc/status_pb2_grpc.py b/src/buildstream/_protos/google/rpc/status_pb2_grpc.py
index a894352..07cb78f 100644
--- a/src/buildstream/_protos/google/rpc/status_pb2_grpc.py
+++ b/src/buildstream/_protos/google/rpc/status_pb2_grpc.py
@@ -1,3 +1,2 @@
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
 import grpc
-
diff --git a/src/buildstream/_remote.py b/src/buildstream/_remote.py
index d8b8e68..9fafc14 100644
--- a/src/buildstream/_remote.py
+++ b/src/buildstream/_remote.py
@@ -21,7 +21,7 @@ from urllib.parse import urlparse
 
 import grpc
 
-from ._exceptions import LoadError, ImplError, RemoteError
+from ._exceptions import ImplError, LoadError, RemoteError
 from .exceptions import LoadErrorReason
 from .types import FastEnum
 
diff --git a/src/buildstream/_scheduler/__init__.py b/src/buildstream/_scheduler/__init__.py
index d689d6e..a40adec 100644
--- a/src/buildstream/_scheduler/__init__.py
+++ b/src/buildstream/_scheduler/__init__.py
@@ -17,14 +17,12 @@
 #  Authors:
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 
+from .jobs import ElementJob, JobStatus
 from .queues import Queue, QueueStatus
-
+from .queues.artifactpushqueue import ArtifactPushQueue
+from .queues.buildqueue import BuildQueue
 from .queues.fetchqueue import FetchQueue
+from .queues.pullqueue import PullQueue
 from .queues.sourcepushqueue import SourcePushQueue
 from .queues.trackqueue import TrackQueue
-from .queues.buildqueue import BuildQueue
-from .queues.artifactpushqueue import ArtifactPushQueue
-from .queues.pullqueue import PullQueue
-
-from .scheduler import Scheduler, SchedStatus, Notification, NotificationType
-from .jobs import ElementJob, JobStatus
+from .scheduler import Notification, NotificationType, SchedStatus, Scheduler
diff --git a/src/buildstream/_scheduler/jobs/elementjob.py b/src/buildstream/_scheduler/jobs/elementjob.py
index 6e035be..e102db1 100644
--- a/src/buildstream/_scheduler/jobs/elementjob.py
+++ b/src/buildstream/_scheduler/jobs/elementjob.py
@@ -19,8 +19,7 @@
 from ruamel import yaml
 
 from ..._message import MessageType
-
-from .job import Job, ChildJob
+from .job import ChildJob, Job
 
 
 # ElementJob()
diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index 78a375f..d9a39b0 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -29,11 +29,11 @@ import signal
 import sys
 import traceback
 
+from ... import _signals, utils
 # BuildStream toplevel imports
-from ..._exceptions import ImplError, BstError, set_last_task_error, SkipJob
+from ..._exceptions import BstError, ImplError, SkipJob, set_last_task_error
 from ..._message import Message, MessageType, unconditional_messages
 from ...types import FastEnum
-from ... import _signals, utils
 from .. import _multiprocessing
 
 
diff --git a/src/buildstream/_scheduler/queues/artifactpushqueue.py b/src/buildstream/_scheduler/queues/artifactpushqueue.py
index 071c6fe..1733960 100644
--- a/src/buildstream/_scheduler/queues/artifactpushqueue.py
+++ b/src/buildstream/_scheduler/queues/artifactpushqueue.py
@@ -18,10 +18,10 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 #        Jürg Billeter <ju...@codethink.co.uk>
 
+from ..._exceptions import SkipJob
+from ..resources import ResourceType
 # Local imports
 from . import Queue, QueueStatus
-from ..resources import ResourceType
-from ..._exceptions import SkipJob
 
 
 # A queue which pushes element artifacts
diff --git a/src/buildstream/_scheduler/queues/buildqueue.py b/src/buildstream/_scheduler/queues/buildqueue.py
index 5cbd5af..95cce9d 100644
--- a/src/buildstream/_scheduler/queues/buildqueue.py
+++ b/src/buildstream/_scheduler/queues/buildqueue.py
@@ -20,10 +20,10 @@
 
 from datetime import timedelta
 
-from . import Queue, QueueStatus
-from ..resources import ResourceType
 from ..._message import MessageType
 from ..jobs import JobStatus
+from ..resources import ResourceType
+from . import Queue, QueueStatus
 
 
 # A queue which assembles elements
diff --git a/src/buildstream/_scheduler/queues/fetchqueue.py b/src/buildstream/_scheduler/queues/fetchqueue.py
index 18bf392..0af00dc 100644
--- a/src/buildstream/_scheduler/queues/fetchqueue.py
+++ b/src/buildstream/_scheduler/queues/fetchqueue.py
@@ -18,10 +18,10 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 #        Jürg Billeter <ju...@codethink.co.uk>
 
+from ..jobs import JobStatus
+from ..resources import ResourceType
 # Local imports
 from . import Queue, QueueStatus
-from ..resources import ResourceType
-from ..jobs import JobStatus
 
 
 # A queue which fetches element sources
diff --git a/src/buildstream/_scheduler/queues/pullqueue.py b/src/buildstream/_scheduler/queues/pullqueue.py
index e1d6959..757619a 100644
--- a/src/buildstream/_scheduler/queues/pullqueue.py
+++ b/src/buildstream/_scheduler/queues/pullqueue.py
@@ -18,11 +18,11 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 #        Jürg Billeter <ju...@codethink.co.uk>
 
+from ..._exceptions import SkipJob
+from ..jobs import JobStatus
+from ..resources import ResourceType
 # Local imports
 from . import Queue, QueueStatus
-from ..resources import ResourceType
-from ..jobs import JobStatus
-from ..._exceptions import SkipJob
 
 
 # A queue which pulls element artifacts
diff --git a/src/buildstream/_scheduler/queues/queue.py b/src/buildstream/_scheduler/queues/queue.py
index 986ac6c..f9848fc 100644
--- a/src/buildstream/_scheduler/queues/queue.py
+++ b/src/buildstream/_scheduler/queues/queue.py
@@ -18,21 +18,20 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 #        Jürg Billeter <ju...@codethink.co.uk>
 
+import heapq
 # System imports
 import os
-from collections import deque
-import heapq
 import traceback
+from collections import deque
 from typing import TYPE_CHECKING
 
-# Local imports
-from ..jobs import ElementJob, JobStatus
-from ..resources import ResourceType
-
 # BuildStream toplevel imports
 from ..._exceptions import BstError, ImplError, set_last_task_error
 from ..._message import Message, MessageType
 from ...types import FastEnum
+# Local imports
+from ..jobs import ElementJob, JobStatus
+from ..resources import ResourceType
 
 if TYPE_CHECKING:
     from typing import List, Optional
diff --git a/src/buildstream/_scheduler/queues/sourcepushqueue.py b/src/buildstream/_scheduler/queues/sourcepushqueue.py
index 8971221..c1cc267 100644
--- a/src/buildstream/_scheduler/queues/sourcepushqueue.py
+++ b/src/buildstream/_scheduler/queues/sourcepushqueue.py
@@ -17,9 +17,9 @@
 #  Authors:
 #        Raoul Hidalgo Charman <ra...@codethink.co.uk>
 
-from . import Queue, QueueStatus
-from ..resources import ResourceType
 from ..._exceptions import SkipJob
+from ..resources import ResourceType
+from . import Queue, QueueStatus
 
 
 # A queue which pushes staged sources
diff --git a/src/buildstream/_scheduler/queues/trackqueue.py b/src/buildstream/_scheduler/queues/trackqueue.py
index d9c31ac..6657ce6 100644
--- a/src/buildstream/_scheduler/queues/trackqueue.py
+++ b/src/buildstream/_scheduler/queues/trackqueue.py
@@ -20,11 +20,10 @@
 
 # BuildStream toplevel imports
 from ...plugin import Plugin
-
+from ..jobs import JobStatus
+from ..resources import ResourceType
 # Local imports
 from . import Queue, QueueStatus
-from ..resources import ResourceType
-from ..jobs import JobStatus
 
 
 # A queue which tracks sources
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 66174ad..60a6843 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -19,22 +19,21 @@
 #        Tristan Van Berkom <tr...@codethink.co.uk>
 #        Jürg Billeter <ju...@codethink.co.uk>
 
+import asyncio
+import datetime
 # System imports
 import os
-import asyncio
-from itertools import chain
 import signal
-import datetime
 import sys
+from itertools import chain
 
-# Local imports
-from .resources import Resources
-from .jobs import JobStatus
-from ..types import FastEnum
-from .._profile import Topics, PROFILER
 from .._message import Message, MessageType
+from .._profile import PROFILER, Topics
 from ..plugin import Plugin
-
+from ..types import FastEnum
+from .jobs import JobStatus
+# Local imports
+from .resources import Resources
 
 _MAX_TIMEOUT_TO_KILL_CHILDREN = 20  # in seconds
 
diff --git a/src/buildstream/_signals.py b/src/buildstream/_signals.py
index 03b55b0..d760aaf 100644
--- a/src/buildstream/_signals.py
+++ b/src/buildstream/_signals.py
@@ -21,11 +21,10 @@ import signal
 import sys
 import threading
 import traceback
-from contextlib import contextmanager, ExitStack
 from collections import deque
+from contextlib import ExitStack, contextmanager
 from typing import Callable, Deque
 
-
 # Global per process state for handling of sigterm/sigtstp/sigcont,
 # note that it is expected that this only ever be used by new processes
 # the scheduler starts, not the main process.
diff --git a/src/buildstream/_sourcecache.py b/src/buildstream/_sourcecache.py
index dcde0b4..cd485ce 100644
--- a/src/buildstream/_sourcecache.py
+++ b/src/buildstream/_sourcecache.py
@@ -18,15 +18,16 @@
 #        Raoul Hidalgo Charman <ra...@codethink.co.uk>
 #
 import os
+
 import grpc
 
-from ._remote import BaseRemote
-from ._cas.casremote import BlobNotFound
-from .storage._casbaseddirectory import CasBasedDirectory
-from ._basecache import BaseCache
-from ._exceptions import CASError, CASRemoteError, SourceCacheError, RemoteError
 from . import utils
+from ._basecache import BaseCache
+from ._cas.casremote import BlobNotFound
+from ._exceptions import CASError, CASRemoteError, RemoteError, SourceCacheError
 from ._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc, source_pb2, source_pb2_grpc
+from ._remote import BaseRemote
+from .storage._casbaseddirectory import CasBasedDirectory
 
 
 class SourceRemote(BaseRemote):
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 3d646a7..ffe2b63 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -20,41 +20,40 @@
 #        Tristan Maat <tr...@codethink.co.uk>
 
 import os
-import sys
-import stat
 import shlex
 import shutil
+import stat
+import sys
 import tarfile
 import tempfile
+from collections import deque
 from contextlib import contextmanager, suppress
 from fnmatch import fnmatch
-from collections import deque
 from typing import List, Tuple
 
-from ._artifactelement import verify_artifact_ref, ArtifactElement
-from ._exceptions import StreamError, ImplError, BstError, ArtifactElementError, ArtifactError
+from . import Scope, _site, _yaml, utils
+from ._artifactelement import ArtifactElement, verify_artifact_ref
+from ._exceptions import ArtifactElementError, ArtifactError, BstError, ImplError, StreamError
 from ._message import Message, MessageType
+from ._pipeline import Pipeline
+from ._profile import PROFILER, Topics
 from ._scheduler import (
-    Scheduler,
-    SchedStatus,
-    TrackQueue,
-    FetchQueue,
-    SourcePushQueue,
-    BuildQueue,
-    PullQueue,
     ArtifactPushQueue,
-    NotificationType,
-    Notification,
+    BuildQueue,
+    FetchQueue,
     JobStatus,
+    Notification,
+    NotificationType,
+    PullQueue,
+    SchedStatus,
+    Scheduler,
+    SourcePushQueue,
+    TrackQueue,
 )
-from .element import Element
-from ._pipeline import Pipeline
-from ._profile import Topics, PROFILER
 from ._state import State
-from .types import _KeyStrength, _PipelineSelection, _SchedulerErrorAction
+from .element import Element
 from .plugin import Plugin
-from . import utils, _yaml, _site
-from . import Scope
+from .types import _KeyStrength, _PipelineSelection, _SchedulerErrorAction
 
 
 # Stream()
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py
index a54a17f..f79f2ee 100644
--- a/src/buildstream/_workspaces.py
+++ b/src/buildstream/_workspaces.py
@@ -18,13 +18,11 @@
 #        Tristan Maat <tr...@codethink.co.uk>
 
 import os
-from . import utils
-from . import _yaml
 
+from . import _yaml, utils
 from ._exceptions import LoadError
 from .exceptions import LoadErrorReason
 
-
 BST_WORKSPACE_FORMAT_VERSION = 4
 BST_WORKSPACE_PROJECT_FORMAT_VERSION = 1
 WORKSPACE_PROJECT_FILE = ".bstproject.yaml"
diff --git a/src/buildstream/buildelement.py b/src/buildstream/buildelement.py
index aa42706..4c30b02 100644
--- a/src/buildstream/buildelement.py
+++ b/src/buildstream/buildelement.py
@@ -141,7 +141,6 @@ from .element import Element
 from .sandbox import SandboxFlags
 from .types import Scope
 
-
 # This list is preserved because of an unfortunate situation, we
 # need to remove these older commands which were secret and never
 # documented, but without breaking the cache keys.
diff --git a/src/buildstream/downloadablefilesource.py b/src/buildstream/downloadablefilesource.py
index 7c2da1c..40164ca 100644
--- a/src/buildstream/downloadablefilesource.py
+++ b/src/buildstream/downloadablefilesource.py
@@ -32,15 +32,15 @@ implementation.
 """
 
 
-import os
-import urllib.request
-import urllib.error
 import contextlib
-import shutil
 import netrc
+import os
+import shutil
+import urllib.error
+import urllib.request
 
-from .source import Source, SourceError
 from . import utils
+from .source import Source, SourceError
 
 
 class _NetrcFTPOpener(urllib.request.FTPHandler):
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 6a0fa5f..2fb3965 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -72,42 +72,37 @@ Class Reference
 ---------------
 """
 
+import contextlib
+import copy
 import os
 import re
 import stat
-import copy
+import string
 import warnings
 from collections import OrderedDict
-import contextlib
 from contextlib import contextmanager
 from functools import partial
 from itertools import chain
-import string
-from typing import cast, TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Set
+from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Set, cast
 
 from pyroaring import BitMap  # pylint: disable=no-name-in-module
 
-from . import _yaml
+from . import _cachekey, _site, _yaml, utils
+from ._artifact import Artifact
+from ._exceptions import BstError, ImplError, LoadError, SourceCacheError
 from ._variables import Variables
 from ._versions import BST_CORE_ARTIFACT_VERSION
-from ._exceptions import BstError, LoadError, ImplError, SourceCacheError
 from .exceptions import ErrorDomain, LoadErrorReason
-from .utils import FileListResult, BST_ARBITRARY_TIMESTAMP
-from . import utils
-from . import _cachekey
-from . import _site
 from .node import Node
 from .plugin import Plugin
-from .sandbox import SandboxFlags, SandboxCommandError
+from .sandbox import SandboxCommandError, SandboxFlags
 from .sandbox._config import SandboxConfig
 from .sandbox._sandboxremote import SandboxRemote
-from .types import CoreWarnings, Scope, _CacheBuildTrees, _KeyStrength
-from ._artifact import Artifact
-
-from .storage.directory import Directory
-from .storage._filebaseddirectory import FileBasedDirectory
 from .storage._casbaseddirectory import CasBasedDirectory
-from .storage.directory import VirtualDirectoryError
+from .storage._filebaseddirectory import FileBasedDirectory
+from .storage.directory import Directory, VirtualDirectoryError
+from .types import CoreWarnings, Scope, _CacheBuildTrees, _KeyStrength
+from .utils import BST_ARBITRARY_TIMESTAMP, FileListResult
 
 if TYPE_CHECKING:
     from .node import MappingNode, ScalarNode, SequenceNode
diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py
index 14e22e5..e2b1331 100644
--- a/src/buildstream/plugin.py
+++ b/src/buildstream/plugin.py
@@ -114,11 +114,11 @@ import os
 import subprocess
 import sys
 from contextlib import contextmanager
-from typing import Generator, Optional, Tuple, TYPE_CHECKING
+from typing import TYPE_CHECKING, Generator, Optional, Tuple
 from weakref import WeakValueDictionary
 
 from . import utils
-from ._exceptions import PluginError, ImplError
+from ._exceptions import ImplError, PluginError
 from ._message import Message, MessageType
 from .node import MappingNode, ProvenanceInformation
 from .types import CoreWarnings, SourceRef
diff --git a/src/buildstream/plugins/elements/compose.py b/src/buildstream/plugins/elements/compose.py
index 9c136df..86d3393 100644
--- a/src/buildstream/plugins/elements/compose.py
+++ b/src/buildstream/plugins/elements/compose.py
@@ -34,6 +34,7 @@ The default configuration and possible options are as such:
 """
 
 import os
+
 from buildstream import Element, Scope
 
 
diff --git a/src/buildstream/plugins/elements/import.py b/src/buildstream/plugins/elements/import.py
index de7ee8a..133edad 100644
--- a/src/buildstream/plugins/elements/import.py
+++ b/src/buildstream/plugins/elements/import.py
@@ -31,6 +31,7 @@ The empty configuration is as such:
 """
 
 import os
+
 from buildstream import Element, ElementError
 
 
diff --git a/src/buildstream/plugins/sources/bzr.py b/src/buildstream/plugins/sources/bzr.py
index 93b5544..e8e000d 100644
--- a/src/buildstream/plugins/sources/bzr.py
+++ b/src/buildstream/plugins/sources/bzr.py
@@ -54,13 +54,12 @@ See :ref:`built-in functionality doumentation <core_source_builtins>` for
 details on common configuration options for sources.
 """
 
+import fcntl
 import os
 import shutil
-import fcntl
 from contextlib import contextmanager
 
-from buildstream import Source, SourceError
-from buildstream import utils
+from buildstream import Source, SourceError, utils
 
 
 class BzrSource(Source):
diff --git a/src/buildstream/plugins/sources/local.py b/src/buildstream/plugins/sources/local.py
index ffcae49..7b4f559 100644
--- a/src/buildstream/plugins/sources/local.py
+++ b/src/buildstream/plugins/sources/local.py
@@ -37,8 +37,9 @@ details on common configuration options for sources.
 """
 
 import os
-from buildstream.storage.directory import Directory
+
 from buildstream import Source, SourceError
+from buildstream.storage.directory import Directory
 
 
 class LocalSource(Source):
diff --git a/src/buildstream/plugins/sources/patch.py b/src/buildstream/plugins/sources/patch.py
index 18672df..62a79fb 100644
--- a/src/buildstream/plugins/sources/patch.py
+++ b/src/buildstream/plugins/sources/patch.py
@@ -45,8 +45,8 @@ details on common configuration options for sources.
 """
 
 import os
-from buildstream import Source, SourceError
-from buildstream import utils
+
+from buildstream import Source, SourceError, utils
 
 
 class PatchSource(Source):
diff --git a/src/buildstream/plugins/sources/remote.py b/src/buildstream/plugins/sources/remote.py
index 9ed3099..ab89bb1 100644
--- a/src/buildstream/plugins/sources/remote.py
+++ b/src/buildstream/plugins/sources/remote.py
@@ -48,6 +48,7 @@ See :ref:`built-in functionality doumentation <core_source_builtins>` for
 details on common configuration options for sources.
 """
 import os
+
 from buildstream import DownloadableFileSource, SourceError, utils
 
 
diff --git a/src/buildstream/plugins/sources/tar.py b/src/buildstream/plugins/sources/tar.py
index aba927b..3f455b4 100644
--- a/src/buildstream/plugins/sources/tar.py
+++ b/src/buildstream/plugins/sources/tar.py
@@ -60,8 +60,7 @@ import tarfile
 from contextlib import contextmanager
 from tempfile import TemporaryFile
 
-from buildstream import DownloadableFileSource, SourceError
-from buildstream import utils
+from buildstream import DownloadableFileSource, SourceError, utils
 
 
 class ReadableTarInfo(tarfile.TarInfo):
diff --git a/src/buildstream/plugins/sources/workspace.py b/src/buildstream/plugins/sources/workspace.py
index 44d0889..129df21 100644
--- a/src/buildstream/plugins/sources/workspace.py
+++ b/src/buildstream/plugins/sources/workspace.py
@@ -37,10 +37,10 @@ workspace. The node constructed would be specified as follows:
 
 import os
 
-from buildstream.storage.directory import Directory
 from buildstream import Source, SourceError
-from buildstream.types import SourceRef
 from buildstream.node import MappingNode
+from buildstream.storage.directory import Directory
+from buildstream.types import SourceRef
 
 
 class WorkspaceSource(Source):
diff --git a/src/buildstream/plugins/sources/zip.py b/src/buildstream/plugins/sources/zip.py
index 1164259..3e5a273 100644
--- a/src/buildstream/plugins/sources/zip.py
+++ b/src/buildstream/plugins/sources/zip.py
@@ -57,11 +57,10 @@ details on common configuration options for sources.
 """
 
 import os
-import zipfile
 import stat
+import zipfile
 
-from buildstream import DownloadableFileSource, SourceError
-from buildstream import utils
+from buildstream import DownloadableFileSource, SourceError, utils
 
 
 class ZipSource(DownloadableFileSource):
diff --git a/src/buildstream/sandbox/__init__.py b/src/buildstream/sandbox/__init__.py
index 5966d19..35846fe 100644
--- a/src/buildstream/sandbox/__init__.py
+++ b/src/buildstream/sandbox/__init__.py
@@ -17,6 +17,6 @@
 #  Authors:
 #        Tristan Maat <tr...@codethink.co.uk>
 
-from .sandbox import Sandbox, SandboxFlags, SandboxCommandError
-from ._sandboxremote import SandboxRemote
 from ._sandboxdummy import SandboxDummy
+from ._sandboxremote import SandboxRemote
+from .sandbox import Sandbox, SandboxCommandError, SandboxFlags
diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py
index 3d71b74..607c2d1 100644
--- a/src/buildstream/sandbox/_sandboxbuildboxrun.py
+++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py
@@ -22,12 +22,12 @@ from contextlib import ExitStack
 
 import psutil
 
-from .. import utils, _signals
-from . import SandboxFlags
+from .. import _signals, utils
 from .._exceptions import SandboxError
 from .._message import Message, MessageType
 from .._platform import Platform
 from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
+from . import SandboxFlags
 from ._sandboxreapi import SandboxREAPI
 
 
diff --git a/src/buildstream/sandbox/_sandboxreapi.py b/src/buildstream/sandbox/_sandboxreapi.py
index 5c28515..2e3e29a 100644
--- a/src/buildstream/sandbox/_sandboxreapi.py
+++ b/src/buildstream/sandbox/_sandboxreapi.py
@@ -17,10 +17,10 @@
 import os
 import shlex
 
-from .sandbox import Sandbox, SandboxFlags, SandboxCommandError, _SandboxBatch
 from .. import utils
 from .._exceptions import ImplError, SandboxError
 from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
+from .sandbox import Sandbox, SandboxCommandError, SandboxFlags, _SandboxBatch
 
 
 # SandboxREAPI()
diff --git a/src/buildstream/sandbox/_sandboxremote.py b/src/buildstream/sandbox/_sandboxremote.py
index 41fb9e1..abcb482 100644
--- a/src/buildstream/sandbox/_sandboxremote.py
+++ b/src/buildstream/sandbox/_sandboxremote.py
@@ -21,23 +21,21 @@
 import os
 import shutil
 from collections import namedtuple
-from urllib.parse import urlparse
 from functools import partial
+from urllib.parse import urlparse
 
 import grpc
 
-from .. import utils
-from ..node import Node
+from .. import _signals, _yaml, utils
+from .._cas import CASRemote
+from .._exceptions import BstError, SandboxError
 from .._message import Message, MessageType
-from ._sandboxreapi import SandboxREAPI
-from .. import _signals
 from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc
-from .._protos.google.rpc import code_pb2
-from .._exceptions import BstError, SandboxError
-from .. import _yaml
 from .._protos.google.longrunning import operations_pb2, operations_pb2_grpc
-from .._cas import CASRemote
+from .._protos.google.rpc import code_pb2
 from .._remote import RemoteSpec
+from ..node import Node
+from ._sandboxreapi import SandboxREAPI
 
 
 class RemoteExecutionSpec(namedtuple("RemoteExecutionSpec", "exec_service storage_service action_service")):
diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py
index 592866d..3465e5e 100644
--- a/src/buildstream/sandbox/sandbox.py
+++ b/src/buildstream/sandbox/sandbox.py
@@ -29,16 +29,16 @@ conform to this interface.
 See also: :ref:`sandboxing`.
 """
 
+import contextlib
 import os
 import shlex
-import contextlib
 from contextlib import contextmanager
-from typing import Dict, Generator, List, Optional, TYPE_CHECKING
+from typing import TYPE_CHECKING, Dict, Generator, List, Optional
 
-from .._exceptions import ImplError, BstError, SandboxError
+from .._exceptions import BstError, ImplError, SandboxError
 from .._message import Message, MessageType
-from ..storage.directory import Directory
 from ..storage._casbaseddirectory import CasBasedDirectory
+from ..storage.directory import Directory
 
 if TYPE_CHECKING:
     from typing import Union
diff --git a/src/buildstream/scriptelement.py b/src/buildstream/scriptelement.py
index f8deff2..270328c 100644
--- a/src/buildstream/scriptelement.py
+++ b/src/buildstream/scriptelement.py
@@ -34,7 +34,7 @@ implementations.
 
 import os
 from collections import OrderedDict
-from typing import List, Optional, TYPE_CHECKING
+from typing import TYPE_CHECKING, List, Optional
 
 from .element import Element, ElementError
 from .sandbox import SandboxFlags
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index f15d5a6..9726d25 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -159,21 +159,20 @@ Class Reference
 
 import os
 from contextlib import contextmanager
-from typing import Iterable, Iterator, Optional, Tuple, TYPE_CHECKING
+from typing import TYPE_CHECKING, Iterable, Iterator, Optional, Tuple
 
 from . import _yaml, utils
-from .node import MappingNode
-from .plugin import Plugin
-from .types import SourceRef, Union, List
+from ._cachekey import generate_key
 from ._exceptions import BstError, ImplError, PluginError
-from .exceptions import ErrorDomain
 from ._loader.metasource import MetaSource
 from ._projectrefs import ProjectRefStorage
-from ._cachekey import generate_key
-from .storage import CasBasedDirectory
-from .storage import FileBasedDirectory
-from .storage.directory import Directory, VirtualDirectoryError
 from ._variables import Variables
+from .exceptions import ErrorDomain
+from .node import MappingNode
+from .plugin import Plugin
+from .storage import CasBasedDirectory, FileBasedDirectory
+from .storage.directory import Directory, VirtualDirectoryError
+from .types import List, SourceRef, Union
 
 if TYPE_CHECKING:
     from typing import Any, Dict, Set
diff --git a/src/buildstream/storage/__init__.py b/src/buildstream/storage/__init__.py
index 5571cd8..d1fabe4 100644
--- a/src/buildstream/storage/__init__.py
+++ b/src/buildstream/storage/__init__.py
@@ -18,6 +18,6 @@
 #  Authors:
 #        Jim MacArthur <ji...@codethink.co.uk>
 
-from ._filebaseddirectory import FileBasedDirectory
 from ._casbaseddirectory import CasBasedDirectory
+from ._filebaseddirectory import FileBasedDirectory
 from .directory import Directory
diff --git a/src/buildstream/storage/_casbaseddirectory.py b/src/buildstream/storage/_casbaseddirectory.py
index 72a6bee..6a55ad6 100644
--- a/src/buildstream/storage/_casbaseddirectory.py
+++ b/src/buildstream/storage/_casbaseddirectory.py
@@ -32,13 +32,14 @@ import stat
 import tarfile as tarfilelib
 from contextlib import contextmanager
 from io import StringIO
+
 from google.protobuf import timestamp_pb2
 
 from .. import utils
 from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
-from .directory import Directory, VirtualDirectoryError, _FileType
+from ..utils import BST_ARBITRARY_TIMESTAMP, FileListResult
 from ._filebaseddirectory import FileBasedDirectory
-from ..utils import FileListResult, BST_ARBITRARY_TIMESTAMP
+from .directory import Directory, VirtualDirectoryError, _FileType
 
 
 class IndexEntry:
diff --git a/src/buildstream/storage/_filebaseddirectory.py b/src/buildstream/storage/_filebaseddirectory.py
index 3f1fc59..ad3befa 100644
--- a/src/buildstream/storage/_filebaseddirectory.py
+++ b/src/buildstream/storage/_filebaseddirectory.py
@@ -31,11 +31,18 @@ import os
 import shutil
 import stat
 
-from .directory import Directory, VirtualDirectoryError, _FileType
 from .. import utils
-from ..utils import link_files, copy_files, list_relative_paths, _get_link_mtime, BST_ARBITRARY_TIMESTAMP
-from ..utils import _set_deterministic_user, _set_deterministic_mtime
-from ..utils import FileListResult
+from ..utils import (
+    BST_ARBITRARY_TIMESTAMP,
+    FileListResult,
+    _get_link_mtime,
+    _set_deterministic_mtime,
+    _set_deterministic_user,
+    copy_files,
+    link_files,
+    list_relative_paths,
+)
+from .directory import Directory, VirtualDirectoryError, _FileType
 
 # FileBasedDirectory intentionally doesn't call its superclass constuctor,
 # which is meant to be unimplemented.
diff --git a/src/buildstream/storage/directory.py b/src/buildstream/storage/directory.py
index f9ea404..5aed774 100644
--- a/src/buildstream/storage/directory.py
+++ b/src/buildstream/storage/directory.py
@@ -34,7 +34,7 @@ See also: :ref:`sandboxing`.
 
 import os
 import stat
-from typing import Callable, Optional, Union, List
+from typing import Callable, List, Optional, Union
 
 from .._exceptions import BstError
 from ..exceptions import ErrorDomain
diff --git a/src/buildstream/testing/__init__.py b/src/buildstream/testing/__init__.py
index f09c5bd..65b7b07 100644
--- a/src/buildstream/testing/__init__.py
+++ b/src/buildstream/testing/__init__.py
@@ -21,13 +21,15 @@ This package contains various utilities which make it easier to test plugins.
 
 import os
 from collections import OrderedDict
-from buildstream.exceptions import ErrorDomain, LoadErrorReason
+
 from buildstream._yaml import load as load_yaml  # type: ignore
-from ._yaml import generate_project, generate_element
+from buildstream.exceptions import ErrorDomain, LoadErrorReason
+
+from ._cachekeys import check_cache_key_stability
+from ._yaml import generate_element, generate_project
+from .integration import integration_cache
 from .repo import Repo
 from .runcli import cli, cli_integration, cli_remote_execution
-from .integration import integration_cache
-from ._cachekeys import check_cache_key_stability
 
 __all__ = [
     "check_cache_key_stability",
diff --git a/src/buildstream/testing/_fixtures.py b/src/buildstream/testing/_fixtures.py
index 5da51bb..dd7c5e9 100644
--- a/src/buildstream/testing/_fixtures.py
+++ b/src/buildstream/testing/_fixtures.py
@@ -19,6 +19,7 @@ import pytest
 
 from buildstream import node, utils
 
+
 # Catch tests that don't shut down background threads, which could then lead
 # to other tests hanging when BuildStream uses fork().
 @pytest.fixture(autouse=True)
diff --git a/src/buildstream/testing/_sourcetests/build_checkout.py b/src/buildstream/testing/_sourcetests/build_checkout.py
index 782d998..76b97ab 100644
--- a/src/buildstream/testing/_sourcetests/build_checkout.py
+++ b/src/buildstream/testing/_sourcetests/build_checkout.py
@@ -20,11 +20,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.testing import create_repo
-from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream import _yaml
+from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import create_repo
+
 from .utils import kind  # pylint: disable=unused-import
 
 # Project directory
diff --git a/src/buildstream/testing/_sourcetests/conftest.py b/src/buildstream/testing/_sourcetests/conftest.py
index 64dd404..88b623d 100644
--- a/src/buildstream/testing/_sourcetests/conftest.py
+++ b/src/buildstream/testing/_sourcetests/conftest.py
@@ -14,4 +14,5 @@
 #  You should have received a copy of the GNU Lesser General Public
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 
-from .._fixtures import reset_global_node_state, thread_check  # pylint: disable=unused-import
+from .._fixtures import reset_global_node_state  # pylint: disable=unused-import
+from .._fixtures import thread_check
diff --git a/src/buildstream/testing/_sourcetests/fetch.py b/src/buildstream/testing/_sourcetests/fetch.py
index 05b43d7..fbc0df0 100644
--- a/src/buildstream/testing/_sourcetests/fetch.py
+++ b/src/buildstream/testing/_sourcetests/fetch.py
@@ -20,15 +20,16 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
-from .._utils import generate_junction
-from .. import create_repo
+
 from .. import cli  # pylint: disable=unused-import
-from .utils import update_project_configuration
+from .. import create_repo
+from .._utils import generate_junction
 from .utils import kind  # pylint: disable=unused-import
-
+from .utils import update_project_configuration
 
 # Project directory
 TOP_DIR = os.path.dirname(os.path.realpath(__file__))
diff --git a/src/buildstream/testing/_sourcetests/mirror.py b/src/buildstream/testing/_sourcetests/mirror.py
index 6904274..fd07612 100644
--- a/src/buildstream/testing/_sourcetests/mirror.py
+++ b/src/buildstream/testing/_sourcetests/mirror.py
@@ -20,13 +20,15 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain
-from .._utils import generate_junction
-from .. import create_repo
+
 from .. import cli  # pylint: disable=unused-import
+from .. import create_repo
+from .._utils import generate_junction
 from .utils import kind  # pylint: disable=unused-import
 
 # Project directory
diff --git a/src/buildstream/testing/_sourcetests/source_determinism.py b/src/buildstream/testing/_sourcetests/source_determinism.py
index b834f32..e7f3080 100644
--- a/src/buildstream/testing/_sourcetests/source_determinism.py
+++ b/src/buildstream/testing/_sourcetests/source_determinism.py
@@ -20,12 +20,14 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
-from .._utils.site import HAVE_SANDBOX, CASD_SEPARATE_USER
-from .. import create_repo
+
 from .. import cli  # pylint: disable=unused-import
+from .. import create_repo
+from .._utils.site import CASD_SEPARATE_USER, HAVE_SANDBOX
 from .utils import kind  # pylint: disable=unused-import
 
 # Project directory
diff --git a/src/buildstream/testing/_sourcetests/track.py b/src/buildstream/testing/_sourcetests/track.py
index ecb508b..25a2b91 100644
--- a/src/buildstream/testing/_sourcetests/track.py
+++ b/src/buildstream/testing/_sourcetests/track.py
@@ -20,16 +20,17 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain
-from .._utils import generate_junction
-from .. import create_repo
+
 from .. import cli  # pylint: disable=unused-import
-from .utils import update_project_configuration
+from .. import create_repo
+from .._utils import generate_junction
 from .utils import kind  # pylint: disable=unused-import
-
+from .utils import update_project_configuration
 
 # Project directory
 TOP_DIR = os.path.dirname(os.path.realpath(__file__))
diff --git a/src/buildstream/testing/_sourcetests/track_cross_junction.py b/src/buildstream/testing/_sourcetests/track_cross_junction.py
index 2c41419..89917ac 100644
--- a/src/buildstream/testing/_sourcetests/track_cross_junction.py
+++ b/src/buildstream/testing/_sourcetests/track_cross_junction.py
@@ -24,12 +24,12 @@ import os
 import pytest
 
 from buildstream import _yaml
-from .._utils import generate_junction
-from .. import create_repo, ALL_REPO_KINDS
+
 from .. import cli  # pylint: disable=unused-import
+from .. import ALL_REPO_KINDS, create_repo
+from .._utils import generate_junction
 from .utils import add_plugins_conf
 
-
 # Project directory
 TOP_DIR = os.path.dirname(os.path.realpath(__file__))
 DATA_DIR = os.path.join(TOP_DIR, "project")
diff --git a/src/buildstream/testing/_sourcetests/utils.py b/src/buildstream/testing/_sourcetests/utils.py
index 4cfb696..1331ae1 100644
--- a/src/buildstream/testing/_sourcetests/utils.py
+++ b/src/buildstream/testing/_sourcetests/utils.py
@@ -21,6 +21,10 @@
 
 import os
 
+from buildstream import _yaml
+
+from .. import ALL_REPO_KINDS
+
 # To make use of these test utilities it is necessary to have pytest
 # available. However, we don't want to have a hard dependency on
 # pytest.
@@ -31,9 +35,6 @@ except ImportError:
     msg = "Could not import pytest:\n" "To use the {} module, you must have pytest installed.".format(module_name)
     raise ImportError(msg)
 
-from buildstream import _yaml
-from .. import ALL_REPO_KINDS
-
 
 # kind()
 #
diff --git a/src/buildstream/testing/_sourcetests/workspace.py b/src/buildstream/testing/_sourcetests/workspace.py
index 3520a8c..35418af 100644
--- a/src/buildstream/testing/_sourcetests/workspace.py
+++ b/src/buildstream/testing/_sourcetests/workspace.py
@@ -21,11 +21,13 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream import _yaml
-from .. import create_repo
+
 from .. import cli  # pylint: disable=unused-import
+from .. import create_repo
 from .utils import kind  # pylint: disable=unused-import
 
 # Project directory
diff --git a/src/buildstream/testing/_update_cachekeys.py b/src/buildstream/testing/_update_cachekeys.py
index 219e17f..e588f98 100755
--- a/src/buildstream/testing/_update_cachekeys.py
+++ b/src/buildstream/testing/_update_cachekeys.py
@@ -32,7 +32,7 @@ import os
 import tempfile
 from unittest import mock
 
-from buildstream.testing._cachekeys import _element_filename, _parse_output_keys, _load_expected_keys
+from buildstream.testing._cachekeys import _element_filename, _load_expected_keys, _parse_output_keys
 from buildstream.testing.runcli import Cli
 
 
diff --git a/src/buildstream/testing/_utils/junction.py b/src/buildstream/testing/_utils/junction.py
index 8f80ed6..8e48254 100644
--- a/src/buildstream/testing/_utils/junction.py
+++ b/src/buildstream/testing/_utils/junction.py
@@ -1,9 +1,11 @@
 import subprocess
+
 import pytest
 
 from buildstream import _yaml
+
 from .. import Repo
-from .site import HAVE_GIT, GIT, GIT_ENV
+from .site import GIT, GIT_ENV, HAVE_GIT
 
 
 # generate_junction()
diff --git a/src/buildstream/testing/_utils/site.py b/src/buildstream/testing/_utils/site.py
index d8ace85..a9b2f53 100644
--- a/src/buildstream/testing/_utils/site.py
+++ b/src/buildstream/testing/_utils/site.py
@@ -7,10 +7,9 @@ import subprocess
 import sys
 from typing import Optional  # pylint: disable=unused-import
 
-from buildstream import utils, ProgramNotFoundError
+from buildstream import ProgramNotFoundError, utils
 from buildstream._platform import Platform
 
-
 try:
     GIT = utils.get_host_tool("git")  # type: Optional[str]
     HAVE_GIT = True
diff --git a/src/buildstream/testing/runcli.py b/src/buildstream/testing/runcli.py
index 1e86860..9cb2667 100644
--- a/src/buildstream/testing/runcli.py
+++ b/src/buildstream/testing/runcli.py
@@ -29,17 +29,16 @@ runcli - Test fixtures used for running BuildStream commands
 """
 
 
+import itertools
 import os
 import re
-import sys
 import shutil
+import sys
 import tempfile
-import itertools
 import traceback
-from contextlib import contextmanager, ExitStack
-from ruamel import yaml
-import pytest
+from contextlib import ExitStack, contextmanager
 
+import pytest
 # XXX Using pytest private internals here
 #
 # We use pytest internals to capture the stdout/stderr during
@@ -47,17 +46,17 @@ import pytest
 # CliRunner convenience API (click.testing module) does not support
 # separation of stdout/stderr.
 #
-from _pytest.capture import MultiCapture, FDCapture, FDCaptureBinary
+from _pytest.capture import FDCapture, FDCaptureBinary, MultiCapture
+from ruamel import yaml
 
-# Import the main cli entrypoint
-from buildstream._frontend import cli as bst_cli
 from buildstream import _yaml, node
 from buildstream._cas import CASCache
-from buildstream.element import _get_normal_name, _compose_artifact_name
-
 # Special private exception accessor, for test case purposes
 from buildstream._exceptions import BstError, get_last_exception, get_last_task_error
+# Import the main cli entrypoint
+from buildstream._frontend import cli as bst_cli
 from buildstream._protos.buildstream.v2 import artifact_pb2
+from buildstream.element import _compose_artifact_name, _get_normal_name
 
 
 # Wrapper for the click.testing result
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py
index 9c6761c..0d3d842 100644
--- a/src/buildstream/utils.py
+++ b/src/buildstream/utils.py
@@ -22,36 +22,35 @@ Utilities
 """
 
 import calendar
+import datetime
 import errno
 import hashlib
+import itertools
 import math
 import os
 import re
 import shutil
 import signal
 import stat
-from stat import S_ISDIR
 import subprocess
 import tempfile
 import time
-import datetime
-import itertools
 from contextlib import contextmanager
 from pathlib import Path
-from typing import Callable, IO, Iterable, Iterator, Optional, Tuple, Union
-from dateutil import parser as dateutil_parser
-from google.protobuf import timestamp_pb2
+from stat import S_ISDIR
+from typing import IO, Callable, Iterable, Iterator, Optional, Tuple, Union
 
 import psutil
+from dateutil import parser as dateutil_parser
+from google.protobuf import timestamp_pb2
 
 from . import _signals
 from ._exceptions import BstError
-from .exceptions import ErrorDomain
 from ._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
-
 # Contains utils that have been rewritten in Cython for speed benefits
 # This makes them available when importing from utils
 from ._utils import url_directory_name  # pylint: disable=unused-import
+from .exceptions import ErrorDomain
 
 # The magic number for timestamps: 2011-11-11 11:11:11
 BST_ARBITRARY_TIMESTAMP = calendar.timegm((2011, 11, 11, 11, 11, 11))
diff --git a/tests/artifactcache/artifactservice.py b/tests/artifactcache/artifactservice.py
index c640665..7da7bd8 100644
--- a/tests/artifactcache/artifactservice.py
+++ b/tests/artifactcache/artifactservice.py
@@ -22,10 +22,10 @@ from urllib.parse import urlparse
 import grpc
 import pytest
 
+from buildstream import utils
+from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as re_pb2
 from buildstream._protos.buildstream.v2.artifact_pb2 import Artifact, GetArtifactRequest, UpdateArtifactRequest
 from buildstream._protos.buildstream.v2.artifact_pb2_grpc import ArtifactServiceStub
-from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as re_pb2
-from buildstream import utils
 
 from tests.testutils.artifactshare import create_artifact_share
 
diff --git a/tests/artifactcache/capabilities.py b/tests/artifactcache/capabilities.py
index c8a49f9..be3541a 100644
--- a/tests/artifactcache/capabilities.py
+++ b/tests/artifactcache/capabilities.py
@@ -4,15 +4,14 @@
 import os
 
 import pytest
-from buildstream._project import Project
 
 from buildstream import _yaml
+from buildstream._project import Project
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
-from tests.testutils import dummy_context
 
+from tests.testutils import dummy_context
 from tests.testutils.artifactshare import create_dummy_artifact_share
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
 
diff --git a/tests/artifactcache/config.py b/tests/artifactcache/config.py
index 24d5558..57e167a 100644
--- a/tests/artifactcache/config.py
+++ b/tests/artifactcache/config.py
@@ -6,18 +6,16 @@ import os
 
 import pytest
 
-from buildstream._remote import RemoteSpec, RemoteType
+from buildstream import _yaml
 from buildstream._artifactcache import ArtifactCache
 from buildstream._project import Project
-from buildstream.utils import _deduplicate
-from buildstream import _yaml
+from buildstream._remote import RemoteSpec, RemoteType
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
-
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
+from buildstream.utils import _deduplicate
 
 from tests.testutils import dummy_context
 
-
 DATA_DIR = os.path.dirname(os.path.realpath(__file__))
 cache1 = RemoteSpec(url="https://example.com/cache1", push=True)
 cache2 = RemoteSpec(url="https://example.com/cache2", push=False)
diff --git a/tests/artifactcache/expiry.py b/tests/artifactcache/expiry.py
index f2be797..d33f367 100644
--- a/tests/artifactcache/expiry.py
+++ b/tests/artifactcache/expiry.py
@@ -31,7 +31,6 @@ from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import create_element_size, wait_for_cache_granularity
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "expiry")
 
 
diff --git a/tests/artifactcache/junctions.py b/tests/artifactcache/junctions.py
index df7ee94..14a700b 100644
--- a/tests/artifactcache/junctions.py
+++ b/tests/artifactcache/junctions.py
@@ -3,13 +3,13 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.testing import cli  # pylint: disable=unused-import
 
-from tests.testutils import create_artifact_share, assert_shared, assert_not_shared
-
+from tests.testutils import assert_not_shared, assert_shared, create_artifact_share
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "junctions",)
 
diff --git a/tests/artifactcache/pull.py b/tests/artifactcache/pull.py
index e6eaec9..8617257 100644
--- a/tests/artifactcache/pull.py
+++ b/tests/artifactcache/pull.py
@@ -12,7 +12,6 @@ from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import create_artifact_share, dummy_context
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py
index 7160e05..7628766 100644
--- a/tests/artifactcache/push.py
+++ b/tests/artifactcache/push.py
@@ -5,14 +5,13 @@ import os
 
 import pytest
 
-from buildstream import _yaml, Scope
+from buildstream import Scope, _yaml
 from buildstream._project import Project
 from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
 from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import create_artifact_share, create_split_share, dummy_context
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/cachekey/cachekey.py b/tests/cachekey/cachekey.py
index 9519722..84f1dcc 100644
--- a/tests/cachekey/cachekey.py
+++ b/tests/cachekey/cachekey.py
@@ -39,17 +39,16 @@
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
 
-from collections import OrderedDict
 import os
+from collections import OrderedDict
 
 import pytest
 
-from buildstream.testing._cachekeys import check_cache_key_stability, _parse_output_keys
-from buildstream.testing.runcli import cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import HAVE_BZR, HAVE_GIT, IS_LINUX, MACHINE_ARCH
-from buildstream.plugin import CoreWarnings
 from buildstream import _yaml
-
+from buildstream.plugin import CoreWarnings
+from buildstream.testing._cachekeys import _parse_output_keys, check_cache_key_stability
+from buildstream.testing._utils.site import HAVE_BZR, HAVE_GIT, IS_LINUX, MACHINE_ARCH
+from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
diff --git a/tests/conftest.py b/tests/conftest.py
index bb4611a..14c5d0d 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -28,13 +28,11 @@ from buildstream.testing import register_repo_kind, sourcetests_collection_hook
 from buildstream.testing._fixtures import reset_global_node_state, thread_check  # pylint: disable=unused-import
 from buildstream.testing.integration import integration_cache  # pylint: disable=unused-import
 
-
-from tests.testutils.repo.git import Git
 from tests.testutils.repo.bzr import Bzr
+from tests.testutils.repo.git import Git
 from tests.testutils.repo.tar import Tar
 from tests.testutils.repo.zip import Zip
 
-
 #
 # This file is loaded by pytest, we use it to add a custom
 # `--integration` option to our test suite, and to install
diff --git a/tests/elements/filter.py b/tests/elements/filter.py
index 3bc24c2..ee0d726 100644
--- a/tests/elements/filter.py
+++ b/tests/elements/filter.py
@@ -6,10 +6,10 @@ import shutil
 
 import pytest
 
-from buildstream.testing import create_repo
-from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream.exceptions import ErrorDomain
 from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain
+from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import create_repo
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "filter",)
 
diff --git a/tests/examples/autotools.py b/tests/examples/autotools.py
index c2cd054..9dcb6e2 100644
--- a/tests/examples/autotools.py
+++ b/tests/examples/autotools.py
@@ -2,11 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
+from buildstream.testing._utils.site import HAVE_SANDBOX, IS_LINUX, MACHINE_ARCH
 from buildstream.testing.integration import assert_contains
-from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH, HAVE_SANDBOX
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/examples/developing.py b/tests/examples/developing.py
index 90d33bf..5c69dbe 100644
--- a/tests/examples/developing.py
+++ b/tests/examples/developing.py
@@ -2,11 +2,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
+from buildstream.testing._utils.site import HAVE_SANDBOX, IS_LINUX, MACHINE_ARCH
 from buildstream.testing.integration import assert_contains
-from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH, HAVE_SANDBOX
+
 import tests.testutils.patch as patch
 
 pytestmark = pytest.mark.integration
diff --git a/tests/examples/first-project.py b/tests/examples/first-project.py
index 8783c4a..259f019 100644
--- a/tests/examples/first-project.py
+++ b/tests/examples/first-project.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing.integration import assert_contains
 from buildstream.testing._utils.site import IS_LINUX
-
+from buildstream.testing.integration import assert_contains
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/examples/flatpak-autotools.py b/tests/examples/flatpak-autotools.py
index d20c7e1..29a8bb7 100644
--- a/tests/examples/flatpak-autotools.py
+++ b/tests/examples/flatpak-autotools.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing.integration import assert_contains
 from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH
-
+from buildstream.testing.integration import assert_contains
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/examples/integration-commands.py b/tests/examples/integration-commands.py
index ad270d0..7e3bd7a 100644
--- a/tests/examples/integration-commands.py
+++ b/tests/examples/integration-commands.py
@@ -2,11 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH, HAVE_SANDBOX
-
+from buildstream.testing._utils.site import HAVE_SANDBOX, IS_LINUX, MACHINE_ARCH
 
 pytestmark = pytest.mark.integration
 DATA_DIR = os.path.join(
diff --git a/tests/examples/junctions.py b/tests/examples/junctions.py
index 1bfc9cd..3fc5749 100644
--- a/tests/examples/junctions.py
+++ b/tests/examples/junctions.py
@@ -2,10 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH, HAVE_SANDBOX
+from buildstream.testing._utils.site import HAVE_SANDBOX, IS_LINUX, MACHINE_ARCH
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/examples/running-commands.py b/tests/examples/running-commands.py
index 9f60b72..9929d32 100644
--- a/tests/examples/running-commands.py
+++ b/tests/examples/running-commands.py
@@ -2,11 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH, HAVE_SANDBOX
-
+from buildstream.testing._utils.site import HAVE_SANDBOX, IS_LINUX, MACHINE_ARCH
 
 pytestmark = pytest.mark.integration
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "doc", "examples", "running-commands")
diff --git a/tests/format/assertion.py b/tests/format/assertion.py
index 3ca5072..44330b8 100644
--- a/tests/format/assertion.py
+++ b/tests/format/assertion.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
diff --git a/tests/format/dependencies.py b/tests/format/dependencies.py
index b1a6840..ada120b 100644
--- a/tests/format/dependencies.py
+++ b/tests/format/dependencies.py
@@ -2,6 +2,7 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
diff --git a/tests/format/include.py b/tests/format/include.py
index d57dd8c..f78ee83 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -3,13 +3,15 @@
 
 import os
 import textwrap
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
-from tests.testutils import generate_junction
 
+from tests.testutils import generate_junction
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "include")
diff --git a/tests/format/include_composition.py b/tests/format/include_composition.py
index 3224822..d87d807 100644
--- a/tests/format/include_composition.py
+++ b/tests/format/include_composition.py
@@ -1,10 +1,9 @@
 import os
-
 from contextlib import contextmanager
 
-from buildstream._project import Project
-from buildstream._includes import Includes
 from buildstream import _yaml
+from buildstream._includes import Includes
+from buildstream._project import Project
 
 from tests.testutils import dummy_context
 
diff --git a/tests/format/invalid_keys.py b/tests/format/invalid_keys.py
index b2bab19..cc12c08 100644
--- a/tests/format/invalid_keys.py
+++ b/tests/format/invalid_keys.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
diff --git a/tests/format/junctions.py b/tests/format/junctions.py
index f5858f7..099c7aa 100644
--- a/tests/format/junctions.py
+++ b/tests/format/junctions.py
@@ -10,7 +10,6 @@ from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "junctions",)
 
 
diff --git a/tests/format/link.py b/tests/format/link.py
index e2c9e0b..2be5861 100644
--- a/tests/format/link.py
+++ b/tests/format/link.py
@@ -5,9 +5,8 @@ import os
 
 import pytest
 
-from buildstream.testing import cli  # pylint: disable=unused-import
 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__)), "link",)
 
diff --git a/tests/format/listdirectiveerrors.py b/tests/format/listdirectiveerrors.py
index 77d9b3f..9e4fdae 100644
--- a/tests/format/listdirectiveerrors.py
+++ b/tests/format/listdirectiveerrors.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
diff --git a/tests/format/option-list-directive.py b/tests/format/option-list-directive.py
index 2df5b6f..313741a 100644
--- a/tests/format/option-list-directive.py
+++ b/tests/format/option-list-directive.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 # Project directory
diff --git a/tests/format/optionbool.py b/tests/format/optionbool.py
index 6f56249..75e2ebd 100644
--- a/tests/format/optionbool.py
+++ b/tests/format/optionbool.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
diff --git a/tests/format/optioneltmask.py b/tests/format/optioneltmask.py
index c5b32d1..52deebe 100644
--- a/tests/format/optioneltmask.py
+++ b/tests/format/optioneltmask.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
diff --git a/tests/format/optionenum.py b/tests/format/optionenum.py
index b525347..5dc336e 100644
--- a/tests/format/optionenum.py
+++ b/tests/format/optionenum.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
diff --git a/tests/format/optionexports.py b/tests/format/optionexports.py
index 4f95dc1..8731b90 100644
--- a/tests/format/optionexports.py
+++ b/tests/format/optionexports.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
diff --git a/tests/format/optionflags.py b/tests/format/optionflags.py
index a3c310f..9f87572 100644
--- a/tests/format/optionflags.py
+++ b/tests/format/optionflags.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
diff --git a/tests/format/optionoverrides.py b/tests/format/optionoverrides.py
index ba12e75..dc99908 100644
--- a/tests/format/optionoverrides.py
+++ b/tests/format/optionoverrides.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
diff --git a/tests/format/options.py b/tests/format/options.py
index 4af3495..8920da8 100644
--- a/tests/format/options.py
+++ b/tests/format/options.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
diff --git a/tests/format/project.py b/tests/format/project.py
index d3de672..83063a3 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -2,14 +2,15 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import filetypegenerator
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
 
diff --git a/tests/format/projectoverrides.py b/tests/format/projectoverrides.py
index 16aad2c..d25725c 100644
--- a/tests/format/projectoverrides.py
+++ b/tests/format/projectoverrides.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream import _yaml
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
diff --git a/tests/format/substitutions.py b/tests/format/substitutions.py
index 265f13e..0266195 100644
--- a/tests/format/substitutions.py
+++ b/tests/format/substitutions.py
@@ -2,9 +2,10 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
-from buildstream.testing import cli  # pylint: disable=unused-import
 
+from buildstream.testing import cli  # pylint: disable=unused-import
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project", "default")
 
diff --git a/tests/format/variables.py b/tests/format/variables.py
index c5e8eeb..eb77aab 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -10,7 +10,6 @@ from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "variables")
 
diff --git a/tests/frontend/__init__.py b/tests/frontend/__init__.py
index 65ecda3..dbaf956 100644
--- a/tests/frontend/__init__.py
+++ b/tests/frontend/__init__.py
@@ -1,4 +1,5 @@
 import os
+
 from buildstream import _yaml
 
 
diff --git a/tests/frontend/artifact_delete.py b/tests/frontend/artifact_delete.py
index 2651f56..ecaea35 100644
--- a/tests/frontend/artifact_delete.py
+++ b/tests/frontend/artifact_delete.py
@@ -19,13 +19,14 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.element import _get_normal_name
 from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
-from tests.testutils import create_artifact_share
 
+from tests.testutils import create_artifact_share
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
diff --git a/tests/frontend/artifact_list_contents.py b/tests/frontend/artifact_list_contents.py
index 8bd7bde..aec3953 100644
--- a/tests/frontend/artifact_list_contents.py
+++ b/tests/frontend/artifact_list_contents.py
@@ -19,11 +19,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli  # pylint: disable=unused-import
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/frontend/artifact_log.py b/tests/frontend/artifact_log.py
index 6ea610a..0bc07bc 100644
--- a/tests/frontend/artifact_log.py
+++ b/tests/frontend/artifact_log.py
@@ -19,11 +19,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli  # pylint: disable=unused-import
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/frontend/artifact_show.py b/tests/frontend/artifact_show.py
index de9b78c..fa3f09a 100644
--- a/tests/frontend/artifact_show.py
+++ b/tests/frontend/artifact_show.py
@@ -19,12 +19,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
-from tests.testutils import create_artifact_share
 
+from tests.testutils import create_artifact_share
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index ca88a13..5830fc8 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -1,21 +1,20 @@
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
 
-import os
-import tarfile
 import hashlib
+import os
 import re
+import tarfile
 
 import pytest
 
+from buildstream import _yaml, utils
+from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
-from buildstream.testing._utils.site import IS_WINDOWS, CASD_SEPARATE_USER
-from buildstream import _yaml
-from buildstream.exceptions import ErrorDomain, LoadErrorReason
-from buildstream import utils
+from buildstream.testing._utils.site import CASD_SEPARATE_USER, IS_WINDOWS
 
-from tests.testutils import generate_junction, create_artifact_share
+from tests.testutils import create_artifact_share, generate_junction
 
 from . import configure_project
 
diff --git a/tests/frontend/completions.py b/tests/frontend/completions.py
index a5e3c8e..af26a98 100644
--- a/tests/frontend/completions.py
+++ b/tests/frontend/completions.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.testing import cli  # pylint: disable=unused-import
 
 # Project directory
diff --git a/tests/frontend/compose_splits.py b/tests/frontend/compose_splits.py
index d333b03..33af86d 100644
--- a/tests/frontend/compose_splits.py
+++ b/tests/frontend/compose_splits.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 # Project directory
diff --git a/tests/frontend/configurable_warnings.py b/tests/frontend/configurable_warnings.py
index 53409a5..2002691 100644
--- a/tests/frontend/configurable_warnings.py
+++ b/tests/frontend/configurable_warnings.py
@@ -5,9 +5,9 @@ import os
 
 import pytest
 
-from buildstream.plugin import CoreWarnings
-from buildstream.exceptions import ErrorDomain
 from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain
+from buildstream.plugin import CoreWarnings
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 TOP_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configuredwarning")
diff --git a/tests/frontend/cross_junction_workspace.py b/tests/frontend/cross_junction_workspace.py
index 5e25d1f..ac7746e 100644
--- a/tests/frontend/cross_junction_workspace.py
+++ b/tests/frontend/cross_junction_workspace.py
@@ -2,9 +2,10 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
+from buildstream import _yaml
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
-from buildstream import _yaml
 
 
 def prepare_junction_project(cli, tmpdir):
diff --git a/tests/frontend/default_target.py b/tests/frontend/default_target.py
index bb7a495..540c254 100644
--- a/tests/frontend/default_target.py
+++ b/tests/frontend/default_target.py
@@ -7,6 +7,7 @@ import pytest
 
 from buildstream import _yaml
 from buildstream.testing import cli, create_repo  # pylint: disable=unused-import
+
 from tests.testutils import create_artifact_share
 
 # project directory
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index b2c9d64..1d498d0 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.py
@@ -2,12 +2,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream.testing import generate_project
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import generate_project
 
 from tests.testutils import generate_junction
 
diff --git a/tests/frontend/help.py b/tests/frontend/help.py
index 20a9316..cc21c6b 100644
--- a/tests/frontend/help.py
+++ b/tests/frontend/help.py
@@ -2,6 +2,7 @@
 # pylint: disable=redefined-outer-name
 
 import pytest
+
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 
diff --git a/tests/frontend/init.py b/tests/frontend/init.py
index 3f897fb..a4716b1 100644
--- a/tests/frontend/init.py
+++ b/tests/frontend/init.py
@@ -2,13 +2,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
-from buildstream.testing import cli  # pylint: disable=unused-import
 
-from buildstream import _yaml
-from buildstream import utils
+from buildstream import _yaml, utils
 from buildstream._frontend.app import App
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli  # pylint: disable=unused-import
 
 
 def get_default_min_version():
diff --git a/tests/frontend/interactive_init.py b/tests/frontend/interactive_init.py
index b8cbe52..0865d5f 100644
--- a/tests/frontend/interactive_init.py
+++ b/tests/frontend/interactive_init.py
@@ -2,8 +2,8 @@ import os
 
 import pexpect
 
-from buildstream import _yaml
-from buildstream import utils
+from buildstream import _yaml, utils
+
 from tests.testutils.constants import PEXPECT_TIMEOUT_SHORT
 
 
diff --git a/tests/frontend/large_directory.py b/tests/frontend/large_directory.py
index ea29fd1..47e2fc7 100644
--- a/tests/frontend/large_directory.py
+++ b/tests/frontend/large_directory.py
@@ -18,15 +18,15 @@
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
 
-from contextlib import contextmanager
 import os
-import pytest
+from contextlib import contextmanager
 
 import grpc
+import pytest
 
 from buildstream.testing import cli  # pylint: disable=unused-import
-from tests.testutils import create_artifact_share, assert_shared
 
+from tests.testutils import assert_shared, create_artifact_share
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py
index 6eb0589..da8c4fe 100644
--- a/tests/frontend/logging.py
+++ b/tests/frontend/logging.py
@@ -6,11 +6,10 @@ import re
 
 import pytest
 
-from buildstream.testing import create_repo
-
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import create_repo
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
diff --git a/tests/frontend/mirror.py b/tests/frontend/mirror.py
index bffc754..3bb0a93 100644
--- a/tests/frontend/mirror.py
+++ b/tests/frontend/mirror.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
-from buildstream.testing import create_repo
 from buildstream.testing import cli  # pylint: disable=unused-import
-
+from buildstream.testing import create_repo
 
 # Project directory
 TOP_DIR = os.path.dirname(os.path.realpath(__file__))
diff --git a/tests/frontend/order.py b/tests/frontend/order.py
index fbeb7c3..9c71a4e 100644
--- a/tests/frontend/order.py
+++ b/tests/frontend/order.py
@@ -4,9 +4,10 @@
 import os
 
 import pytest
-from buildstream.testing import create_repo
-from buildstream.testing import cli  # pylint: disable=unused-import
+
 from buildstream import _yaml
+from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import create_repo
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py
index a45fc70..0887ef0 100644
--- a/tests/frontend/overlaps.py
+++ b/tests/frontend/overlaps.py
@@ -2,11 +2,14 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
-from buildstream.testing.runcli import cli  # pylint: disable=unused-import
-from buildstream.exceptions import ErrorDomain
+
 from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain
 from buildstream.plugin import CoreWarnings
+from buildstream.testing.runcli import cli  # pylint: disable=unused-import
+
 from tests.testutils import generate_junction
 
 # Project directory
diff --git a/tests/frontend/progress.py b/tests/frontend/progress.py
index 5d446bb..e6a736d 100644
--- a/tests/frontend/progress.py
+++ b/tests/frontend/progress.py
@@ -2,11 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import generate_junction
 
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py
index c1fa76a..f54ab45 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -4,19 +4,21 @@
 import os
 import shutil
 import stat
+
 import pytest
-from buildstream import utils, _yaml
+
+from buildstream import _yaml, utils
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
+
 from tests.testutils import (
+    assert_not_shared,
+    assert_shared,
     create_artifact_share,
     create_split_share,
     generate_junction,
-    assert_shared,
-    assert_not_shared,
 )
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index 50e3546..a648184 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -25,20 +25,21 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli, generate_project  # pylint: disable=unused-import
+
 from tests.testutils import (
+    assert_not_shared,
+    assert_shared,
     create_artifact_share,
     create_element_size,
     generate_junction,
     wait_for_cache_granularity,
-    assert_shared,
-    assert_not_shared,
 )
 
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/frontend/rebuild.py b/tests/frontend/rebuild.py
index 1aef8e4..0d2100b 100644
--- a/tests/frontend/rebuild.py
+++ b/tests/frontend/rebuild.py
@@ -2,7 +2,9 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
 from buildstream.testing import cli  # pylint: disable=unused-import
 
 # Project directory
diff --git a/tests/frontend/remote-caches.py b/tests/frontend/remote-caches.py
index b112e08..2e66bc5 100644
--- a/tests/frontend/remote-caches.py
+++ b/tests/frontend/remote-caches.py
@@ -21,10 +21,11 @@
 # pylint: disable=redefined-outer-name
 import os
 import shutil
+
 import pytest
 
-from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream import _yaml
+from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import create_artifact_share, create_element_size
 
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index 4be4b72..8468ca5 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -1,14 +1,16 @@
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
 
+import itertools
 import os
-import sys
 import shutil
-import itertools
+import sys
+
 import pytest
-from buildstream.testing import cli  # pylint: disable=unused-import
+
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli  # pylint: disable=unused-import
 
 from tests.testutils import generate_junction
 
diff --git a/tests/frontend/source_checkout.py b/tests/frontend/source_checkout.py
index 58c59ec..d123089 100644
--- a/tests/frontend/source_checkout.py
+++ b/tests/frontend/source_checkout.py
@@ -6,10 +6,9 @@ import tarfile
 
 import pytest
 
+from buildstream import _yaml, utils
 from buildstream.testing import cli  # pylint: disable=unused-import
 
-from buildstream import utils, _yaml
-
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index 2ebaae8..9de0a29 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -1,15 +1,18 @@
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
 
-import stat
 import os
+import stat
+
 import pytest
 
-from buildstream.testing import create_repo
-from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import create_repo
+
 from tests.testutils import generate_junction
+
 from . import configure_project
 
 # Project directory
diff --git a/tests/frontend/version.py b/tests/frontend/version.py
index 279a517..74ed9a5 100644
--- a/tests/frontend/version.py
+++ b/tests/frontend/version.py
@@ -1,11 +1,9 @@
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
 
-from buildstream.testing.runcli import cli  # pylint: disable=unused-import
-
-
 # For utils.get_bst_version()
 from buildstream import utils
+from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 
 def assert_version(cli_version_output):
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 4aae61a..d73f200 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -28,17 +28,17 @@
 # pylint: disable=redefined-outer-name
 
 import os
-import stat
 import shutil
+import stat
 import subprocess
 
 import pytest
 
-from buildstream.testing import create_repo, ALL_REPO_KINDS
-from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream import _yaml
-from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream._workspaces import BST_WORKSPACE_FORMAT_VERSION
+from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import ALL_REPO_KINDS, create_repo
 
 from tests.testutils import create_artifact_share, create_element_size, wait_for_cache_granularity
 
diff --git a/tests/integration/artifact.py b/tests/integration/artifact.py
index e21dd42..36a76f2 100644
--- a/tests/integration/artifact.py
+++ b/tests/integration/artifact.py
@@ -31,7 +31,6 @@ from buildstream.testing._utils.site import HAVE_SANDBOX
 
 from tests.testutils import create_artifact_share
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/autotools.py b/tests/integration/autotools.py
index d1ab82e..e6b1464 100644
--- a/tests/integration/autotools.py
+++ b/tests/integration/autotools.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing.integration import assert_contains
 from buildstream.testing._utils.site import HAVE_SANDBOX
-
+from buildstream.testing.integration import assert_contains
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/integration/build-uid.py b/tests/integration/build-uid.py
index a0cc20d..2eb79a1 100644
--- a/tests/integration/build-uid.py
+++ b/tests/integration/build-uid.py
@@ -2,11 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import HAVE_SANDBOX, BUILDBOX_RUN
-
+from buildstream.testing._utils.site import BUILDBOX_RUN, HAVE_SANDBOX
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/integration/cachedfail.py b/tests/integration/cachedfail.py
index f72c315..64ad809 100644
--- a/tests/integration/cachedfail.py
+++ b/tests/integration/cachedfail.py
@@ -18,16 +18,16 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream import utils, _yaml
+from buildstream import _yaml, utils
 from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
 from tests.testutils import create_artifact_share
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/compose-symlinks.py b/tests/integration/compose-symlinks.py
index 7b807d1..f9e8987 100644
--- a/tests/integration/compose-symlinks.py
+++ b/tests/integration/compose-symlinks.py
@@ -2,11 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/compose.py b/tests/integration/compose.py
index f08f2e8..5f84b18 100644
--- a/tests/integration/compose.py
+++ b/tests/integration/compose.py
@@ -2,14 +2,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
-
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
+from buildstream.testing._utils.site import BUILDBOX_RUN, HAVE_SANDBOX
 from buildstream.testing.integration import walk_dir
-from buildstream.testing._utils.site import HAVE_SANDBOX, BUILDBOX_RUN
-
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/integration/filter.py b/tests/integration/filter.py
index 12061fe..557bf28 100644
--- a/tests/integration/filter.py
+++ b/tests/integration/filter.py
@@ -3,12 +3,12 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing._utils.site import BUILDBOX_RUN, HAVE_SANDBOX
 from buildstream.testing.integration import assert_contains
-from buildstream.testing._utils.site import HAVE_SANDBOX, BUILDBOX_RUN
-
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/integration/import.py b/tests/integration/import.py
index f7510e2..01bf848 100644
--- a/tests/integration/import.py
+++ b/tests/integration/import.py
@@ -2,14 +2,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
-
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing.integration import walk_dir
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/interactive_build.py b/tests/integration/interactive_build.py
index c0b0871..e43b99e 100644
--- a/tests/integration/interactive_build.py
+++ b/tests/integration/interactive_build.py
@@ -2,13 +2,14 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pexpect
 import pytest
 
 from buildstream.testing import runcli
 from buildstream.testing._utils.site import HAVE_SANDBOX
-from tests.testutils.constants import PEXPECT_TIMEOUT_SHORT, PEXPECT_TIMEOUT_LONG
 
+from tests.testutils.constants import PEXPECT_TIMEOUT_LONG, PEXPECT_TIMEOUT_SHORT
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/integration/manual.py b/tests/integration/manual.py
index defc250..110eac1 100644
--- a/tests/integration/manual.py
+++ b/tests/integration/manual.py
@@ -3,14 +3,13 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream import _yaml
-
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/messages.py b/tests/integration/messages.py
index 1a324a6..8cfa3dd 100644
--- a/tests/integration/messages.py
+++ b/tests/integration/messages.py
@@ -21,6 +21,7 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
@@ -28,7 +29,6 @@ from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/pip_source.py b/tests/integration/pip_source.py
index 5d31497..0255624 100644
--- a/tests/integration/pip_source.py
+++ b/tests/integration/pip_source.py
@@ -2,17 +2,16 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
-
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing.integration import assert_contains
 from buildstream.testing._utils.site import HAVE_SANDBOX
+from buildstream.testing.integration import assert_contains
 
 from tests.testutils.python_repo import setup_pypi_repo  # pylint: disable=unused-import
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/pullbuildtrees.py b/tests/integration/pullbuildtrees.py
index 6d9eefb..3209c36 100644
--- a/tests/integration/pullbuildtrees.py
+++ b/tests/integration/pullbuildtrees.py
@@ -6,13 +6,13 @@ import shutil
 
 import pytest
 
-from buildstream.testing import cli, cli_integration as cli2  # pylint: disable=unused-import
-from buildstream.testing._utils.site import HAVE_SANDBOX
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing import cli
+from buildstream.testing import cli_integration as cli2  # pylint: disable=unused-import
+from buildstream.testing._utils.site import HAVE_SANDBOX
 
 from tests.testutils import create_artifact_share
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/sandbox.py b/tests/integration/sandbox.py
index cfa177e..1de1e3b 100644
--- a/tests/integration/sandbox.py
+++ b/tests/integration/sandbox.py
@@ -19,12 +19,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/script.py b/tests/integration/script.py
index 35a3fdd..5038061 100644
--- a/tests/integration/script.py
+++ b/tests/integration/script.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import HAVE_SANDBOX, BUILDBOX_RUN
-
+from buildstream.testing._utils.site import BUILDBOX_RUN, HAVE_SANDBOX
 
 pytestmark = pytest.mark.integration
 
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index 42e486b..2b00014 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -6,15 +6,13 @@ import uuid
 
 import pytest
 
-from buildstream import _yaml
-from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import HAVE_SANDBOX, BUILDBOX_RUN
+from buildstream import _yaml, utils
 from buildstream.exceptions import ErrorDomain
-from buildstream import utils
+from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
+from buildstream.testing._utils.site import BUILDBOX_RUN, HAVE_SANDBOX
 
 from tests.testutils import create_artifact_share
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py
index 0d80c16..b99a754 100644
--- a/tests/integration/shellbuildtrees.py
+++ b/tests/integration/shellbuildtrees.py
@@ -6,13 +6,12 @@ import shutil
 
 import pytest
 
-from buildstream.testing import cli, cli_integration  # pylint: disable=unused-import
 from buildstream.exceptions import ErrorDomain
+from buildstream.testing import cli, cli_integration  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
 from tests.testutils import create_artifact_share
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/sockets.py b/tests/integration/sockets.py
index 3fb656e..32f904b 100644
--- a/tests/integration/sockets.py
+++ b/tests/integration/sockets.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
-
 pytestmark = pytest.mark.integration
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
diff --git a/tests/integration/source-determinism.py b/tests/integration/source-determinism.py
index a69e55a..940de31 100644
--- a/tests/integration/source-determinism.py
+++ b/tests/integration/source-determinism.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
-from buildstream.testing._utils.site import HAVE_SANDBOX, CASD_SEPARATE_USER
-
+from buildstream.testing._utils.site import CASD_SEPARATE_USER, HAVE_SANDBOX
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
 
diff --git a/tests/integration/stack.py b/tests/integration/stack.py
index bad807f..dd0a12a 100644
--- a/tests/integration/stack.py
+++ b/tests/integration/stack.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/symlinks.py b/tests/integration/symlinks.py
index f1d044f..d25a57c 100644
--- a/tests/integration/symlinks.py
+++ b/tests/integration/symlinks.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py
index a2ea484..78e4bc1 100644
--- a/tests/integration/workspace.py
+++ b/tests/integration/workspace.py
@@ -2,17 +2,17 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli_integration as cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
-from buildstream.exceptions import ErrorDomain
 from buildstream.utils import BST_ARBITRARY_TIMESTAMP
 
 from tests.testutils import wait_for_cache_granularity
 
-
 pytestmark = pytest.mark.integration
 
 
diff --git a/tests/internals/context.py b/tests/internals/context.py
index 9d06a68..2743dfa 100644
--- a/tests/internals/context.py
+++ b/tests/internals/context.py
@@ -2,10 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream._context import Context
 from buildstream import _yaml, utils
+from buildstream._context import Context
 from buildstream._exceptions import LoadError
 from buildstream.exceptions import LoadErrorReason
 
diff --git a/tests/internals/loader.py b/tests/internals/loader.py
index bdce428..17cd278 100644
--- a/tests/internals/loader.py
+++ b/tests/internals/loader.py
@@ -1,15 +1,15 @@
-from contextlib import contextmanager
 import os
+from contextlib import contextmanager
+
 import pytest
 
-from buildstream.exceptions import LoadErrorReason
 from buildstream._exceptions import LoadError
-from buildstream._project import Project
 from buildstream._loader import MetaElement
+from buildstream._project import Project
+from buildstream.exceptions import LoadErrorReason
 
 from tests.testutils import dummy_context
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "loader",)
 
 
diff --git a/tests/internals/pluginloading.py b/tests/internals/pluginloading.py
index 1f44465..284c6ff 100644
--- a/tests/internals/pluginloading.py
+++ b/tests/internals/pluginloading.py
@@ -1,9 +1,10 @@
-from contextlib import contextmanager
 import os
+from contextlib import contextmanager
+
 import pytest
 
-from buildstream._project import Project
 from buildstream._pipeline import Pipeline
+from buildstream._project import Project
 
 from tests.testutils import dummy_context
 
diff --git a/tests/internals/storage.py b/tests/internals/storage.py
index e9932e0..410d5fe 100644
--- a/tests/internals/storage.py
+++ b/tests/internals/storage.py
@@ -1,10 +1,10 @@
-from contextlib import contextmanager
+import glob
+import hashlib
 import os
 import pprint
 import shutil
 import stat
-import glob
-import hashlib
+from contextlib import contextmanager
 from pathlib import Path
 from typing import List, Optional
 
@@ -13,7 +13,7 @@ import pytest
 from buildstream._cas import CASCache
 from buildstream.storage._casbaseddirectory import CasBasedDirectory
 from buildstream.storage._filebaseddirectory import FileBasedDirectory
-from buildstream.storage.directory import _FileType, VirtualDirectoryError
+from buildstream.storage.directory import VirtualDirectoryError, _FileType
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "storage")
 
diff --git a/tests/internals/storage_vdir_import.py b/tests/internals/storage_vdir_import.py
index ffd727f..7088225 100644
--- a/tests/internals/storage_vdir_import.py
+++ b/tests/internals/storage_vdir_import.py
@@ -13,18 +13,17 @@
 #
 #  You should have received a copy of the GNU Lesser General Public
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
-from hashlib import sha256
 import os
 import random
+from hashlib import sha256
 
 import pytest
 
+from buildstream._cas import CASCache
 from buildstream.storage._casbaseddirectory import CasBasedDirectory
 from buildstream.storage._filebaseddirectory import FileBasedDirectory
-from buildstream._cas import CASCache
 from buildstream.storage.directory import VirtualDirectoryError
-from buildstream.utils import _set_file_mtime, _parse_timestamp
-
+from buildstream.utils import _parse_timestamp, _set_file_mtime
 
 # These are comparitive tests that check that FileBasedDirectory and
 # CasBasedDirectory act identically.
diff --git a/tests/internals/utils_move_atomic.py b/tests/internals/utils_move_atomic.py
index dd417cb..9022d83 100644
--- a/tests/internals/utils_move_atomic.py
+++ b/tests/internals/utils_move_atomic.py
@@ -4,11 +4,11 @@
 import pytest
 
 from buildstream.utils import (
-    move_atomic,
     DirectoryExistsError,
     _get_file_mtimestamp,
-    _set_file_mtime,
     _parse_timestamp,
+    _set_file_mtime,
+    move_atomic,
 )
 
 
diff --git a/tests/internals/utils_save_atomic.py b/tests/internals/utils_save_atomic.py
index 8982860..d1d3949 100644
--- a/tests/internals/utils_save_atomic.py
+++ b/tests/internals/utils_save_atomic.py
@@ -1,4 +1,5 @@
 import os
+
 import pytest
 
 from buildstream.utils import save_file_atomic
diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py
index a4f8d08..e6509ce 100644
--- a/tests/internals/yaml.py
+++ b/tests/internals/yaml.py
@@ -3,10 +3,9 @@ from io import StringIO
 
 import pytest
 
-from buildstream import _yaml, Node, ProvenanceInformation, SequenceNode
-from buildstream.exceptions import LoadErrorReason
+from buildstream import Node, ProvenanceInformation, SequenceNode, _yaml
 from buildstream._exceptions import LoadError
-
+from buildstream.exceptions import LoadErrorReason
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "yaml",)
 
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py
index 7aeb242..e62cd52 100644
--- a/tests/plugins/loading.py
+++ b/tests/plugins/loading.py
@@ -8,12 +8,12 @@
 
 import os
 import shutil
+
 import pytest
 
+from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream import _yaml
-
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "loading")
 
diff --git a/tests/plugins/sample-plugins/setup.py b/tests/plugins/sample-plugins/setup.py
index 8429c7c..920f19f 100755
--- a/tests/plugins/sample-plugins/setup.py
+++ b/tests/plugins/sample-plugins/setup.py
@@ -16,7 +16,7 @@
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 #
 
-from setuptools import setup, find_packages
+from setuptools import find_packages, setup
 
 setup(
     name="sample-plugins",
diff --git a/tests/remoteexecution/buildfail.py b/tests/remoteexecution/buildfail.py
index 37f4dca..f782939 100644
--- a/tests/remoteexecution/buildfail.py
+++ b/tests/remoteexecution/buildfail.py
@@ -19,10 +19,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.exceptions import ErrorDomain
 from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli_remote_execution as cli  # pylint: disable=unused-import
 
 pytestmark = pytest.mark.remoteexecution
diff --git a/tests/remoteexecution/buildtree.py b/tests/remoteexecution/buildtree.py
index 57e25cd..0c805d6 100644
--- a/tests/remoteexecution/buildtree.py
+++ b/tests/remoteexecution/buildtree.py
@@ -19,6 +19,7 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream.testing import cli_remote_execution as cli  # pylint: disable=unused-import
diff --git a/tests/remoteexecution/junction.py b/tests/remoteexecution/junction.py
index 2b02616..7c39b62 100644
--- a/tests/remoteexecution/junction.py
+++ b/tests/remoteexecution/junction.py
@@ -19,10 +19,13 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
+
+from buildstream import _yaml
 from buildstream.testing import cli_remote_execution as cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
-from buildstream import _yaml
+
 from tests.testutils import generate_junction
 
 pytestmark = pytest.mark.remoteexecution
diff --git a/tests/remoteexecution/partial.py b/tests/remoteexecution/partial.py
index ec5fabe..1ea8fea 100644
--- a/tests/remoteexecution/partial.py
+++ b/tests/remoteexecution/partial.py
@@ -2,6 +2,7 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain
@@ -10,7 +11,6 @@ from buildstream.testing.integration import assert_contains
 
 from tests.testutils.artifactshare import create_artifact_share
 
-
 pytestmark = pytest.mark.remoteexecution
 
 
diff --git a/tests/remoteexecution/simple.py b/tests/remoteexecution/simple.py
index cb8f809..791dbc3 100644
--- a/tests/remoteexecution/simple.py
+++ b/tests/remoteexecution/simple.py
@@ -2,12 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli_remote_execution as cli  # pylint: disable=unused-import
 from buildstream.testing.integration import assert_contains
 
-
 pytestmark = pytest.mark.remoteexecution
 
 
diff --git a/tests/remoteexecution/workspace.py b/tests/remoteexecution/workspace.py
index b525cef..1e8d8ec 100644
--- a/tests/remoteexecution/workspace.py
+++ b/tests/remoteexecution/workspace.py
@@ -4,6 +4,7 @@
 import os
 import re
 import shutil
+
 import pytest
 
 from buildstream.testing import cli_remote_execution as cli  # pylint: disable=unused-import
diff --git a/tests/sandboxes/missing-command.py b/tests/sandboxes/missing-command.py
index ec6ba18..780a872 100644
--- a/tests/sandboxes/missing-command.py
+++ b/tests/sandboxes/missing-command.py
@@ -2,13 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain
-
 from buildstream.testing import cli  # pylint: disable=unused-import
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "missing-command")
 
 
diff --git a/tests/sandboxes/missing_dependencies.py b/tests/sandboxes/missing_dependencies.py
index 7ac7d78..84bc78f 100644
--- a/tests/sandboxes/missing_dependencies.py
+++ b/tests/sandboxes/missing_dependencies.py
@@ -5,11 +5,10 @@ import os
 
 import pytest
 
-from buildstream import utils, _yaml
+from buildstream import _yaml, utils
 from buildstream.exceptions import ErrorDomain
-from buildstream.testing._utils.site import IS_LINUX
 from buildstream.testing import cli  # pylint: disable=unused-import
-
+from buildstream.testing._utils.site import IS_LINUX
 
 # Project directory
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "missing-dependencies",)
diff --git a/tests/sandboxes/selection.py b/tests/sandboxes/selection.py
index 0118fb5..a98395f 100644
--- a/tests/sandboxes/selection.py
+++ b/tests/sandboxes/selection.py
@@ -17,9 +17,10 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream import utils, _yaml
+from buildstream import _yaml, utils
 from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
 
diff --git a/tests/sourcecache/cache.py b/tests/sourcecache/cache.py
index bbc3d83..0f38d2f 100644
--- a/tests/sourcecache/cache.py
+++ b/tests/sourcecache/cache.py
@@ -22,10 +22,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 from buildstream import _yaml
+from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
 
diff --git a/tests/sourcecache/capabilities.py b/tests/sourcecache/capabilities.py
index 9d41eba..8c97fd8 100644
--- a/tests/sourcecache/capabilities.py
+++ b/tests/sourcecache/capabilities.py
@@ -4,15 +4,14 @@
 import os
 
 import pytest
-from buildstream._project import Project
 
 from buildstream import _yaml
+from buildstream._project import Project
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
-from tests.testutils import dummy_context
 
+from tests.testutils import dummy_context
 from tests.testutils.artifactshare import create_dummy_artifact_share
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
 
 
diff --git a/tests/sourcecache/config.py b/tests/sourcecache/config.py
index 0c11a27..514f132 100644
--- a/tests/sourcecache/config.py
+++ b/tests/sourcecache/config.py
@@ -22,11 +22,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
-
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 DATA_DIR = os.path.dirname(os.path.realpath(__file__))
diff --git a/tests/sourcecache/fetch.py b/tests/sourcecache/fetch.py
index 889de62..654fb22 100644
--- a/tests/sourcecache/fetch.py
+++ b/tests/sourcecache/fetch.py
@@ -19,14 +19,15 @@
 #
 # Pylint doesn't play well with fixtures and dependency injection from pytest
 # pylint: disable=redefined-outer-name
-from contextlib import contextmanager
 import os
 import shutil
+from contextlib import contextmanager
+
 import pytest
 
-from buildstream.exceptions import ErrorDomain
-from buildstream._project import Project
 from buildstream import _yaml
+from buildstream._project import Project
+from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
 
diff --git a/tests/sourcecache/project/plugins/elements/always_fail.py b/tests/sourcecache/project/plugins/elements/always_fail.py
index bc3ed57..7dc908e 100644
--- a/tests/sourcecache/project/plugins/elements/always_fail.py
+++ b/tests/sourcecache/project/plugins/elements/always_fail.py
@@ -18,8 +18,8 @@
 #        Raoul Hidalgo Charman <ra...@codethink.co.uk>
 #
 
-from buildstream.element import ElementError
 from buildstream.buildelement import BuildElement
+from buildstream.element import ElementError
 
 
 class AlwaysFail(BuildElement):
diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py
index 9f8663a..ff6ef1c 100644
--- a/tests/sourcecache/push.py
+++ b/tests/sourcecache/push.py
@@ -21,15 +21,16 @@
 # pylint: disable=redefined-outer-name
 import os
 import shutil
-from contextlib import contextmanager, ExitStack
+from contextlib import ExitStack, contextmanager
 
 import pytest
 
-from buildstream.exceptions import ErrorDomain
-from buildstream._project import Project
 from buildstream import _yaml
+from buildstream._project import Project
+from buildstream.exceptions import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing import create_repo
+
 from tests.testutils import create_artifact_share, dummy_context
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
diff --git a/tests/sourcecache/staging.py b/tests/sourcecache/staging.py
index dbfc028..fa30c5c 100644
--- a/tests/sourcecache/staging.py
+++ b/tests/sourcecache/staging.py
@@ -23,16 +23,15 @@
 
 import os
 import shutil
+
 import pytest
 
 from buildstream._project import Project
-
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
 from tests.testutils import dummy_context
 from tests.testutils.element_generators import create_element_size
 
-
 DATA_DIR = os.path.dirname(os.path.realpath(__file__))
 
 
diff --git a/tests/sourcecache/workspace.py b/tests/sourcecache/workspace.py
index bb1ea50..c970296 100644
--- a/tests/sourcecache/workspace.py
+++ b/tests/sourcecache/workspace.py
@@ -31,7 +31,6 @@ from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 from tests.testutils.artifactshare import create_artifact_share
 from tests.testutils.element_generators import create_element_size
 
-
 DATA_DIR = os.path.dirname(os.path.realpath(__file__))
 
 
diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py
index 2dcacfe..2bd4c75 100644
--- a/tests/sources/bzr.py
+++ b/tests/sources/bzr.py
@@ -2,11 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream.testing import create_repo
-from buildstream.testing import generate_element
+from buildstream.testing import create_repo, generate_element
 from buildstream.testing._utils.site import HAVE_BZR
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "bzr")
diff --git a/tests/sources/git.py b/tests/sources/git.py
index 033db1b..d6ac46e 100644
--- a/tests/sources/git.py
+++ b/tests/sources/git.py
@@ -24,8 +24,8 @@
 # pylint: disable=redefined-outer-name
 
 import os
-import subprocess
 import shutil
+import subprocess
 
 import pytest
 
@@ -33,8 +33,7 @@ from buildstream import Node
 from buildstream.exceptions import ErrorDomain
 from buildstream.plugin import CoreWarnings
 from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream.testing import generate_project, generate_element, load_yaml
-from buildstream.testing import create_repo
+from buildstream.testing import create_repo, generate_element, generate_project, load_yaml
 from buildstream.testing._utils.site import HAVE_GIT, HAVE_OLD_GIT
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "git",)
diff --git a/tests/sources/keytest.py b/tests/sources/keytest.py
index 70e01f6..3bee771 100644
--- a/tests/sources/keytest.py
+++ b/tests/sources/keytest.py
@@ -22,10 +22,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.testing import ErrorDomain
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import ErrorDomain
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project_key_test")
 
diff --git a/tests/sources/local.py b/tests/sources/local.py
index 2b01551..2b3bc2a 100644
--- a/tests/sources/local.py
+++ b/tests/sources/local.py
@@ -2,12 +2,14 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream import _yaml
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
 from buildstream.testing._utils.site import HAVE_SANDBOX
+
 from tests.testutils import filetypegenerator
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "local",)
diff --git a/tests/sources/no_fetch_cached.py b/tests/sources/no_fetch_cached.py
index 4984f53..96b94e9 100644
--- a/tests/sources/no_fetch_cached.py
+++ b/tests/sources/no_fetch_cached.py
@@ -2,11 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.testing import cli  # pylint: disable=unused-import
-from buildstream.testing import create_repo
-from buildstream.testing import generate_element
+from buildstream.testing import create_repo, generate_element
 from buildstream.testing._utils.site import HAVE_GIT
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "no-fetch-cached")
diff --git a/tests/sources/patch.py b/tests/sources/patch.py
index 5392a64..99068f0 100644
--- a/tests/sources/patch.py
+++ b/tests/sources/patch.py
@@ -2,10 +2,12 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing import cli  # pylint: disable=unused-import
+
 from tests.testutils import filetypegenerator
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "patch",)
diff --git a/tests/sources/pip.py b/tests/sources/pip.py
index 1eacb44..44a5aa4 100644
--- a/tests/sources/pip.py
+++ b/tests/sources/pip.py
@@ -2,6 +2,7 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
 from buildstream.exceptions import ErrorDomain
diff --git a/tests/sources/previous_source_access.py b/tests/sources/previous_source_access.py
index 3c95d77..15d0993 100644
--- a/tests/sources/previous_source_access.py
+++ b/tests/sources/previous_source_access.py
@@ -2,10 +2,11 @@
 # pylint: disable=redefined-outer-name
 
 import os
+
 import pytest
 
-from buildstream.testing import generate_project, load_yaml
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import generate_project, load_yaml
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "previous_source_access")
 
diff --git a/tests/sources/previous_source_access/plugins/sources/foo_transform.py b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
index 15fef43..9b9e1ad 100644
--- a/tests/sources/previous_source_access/plugins/sources/foo_transform.py
+++ b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
@@ -7,8 +7,8 @@ previous sources, and copies its contents to a file called "filetransform".
 
 """
 
-import os
 import hashlib
+import os
 
 from buildstream import Source, SourceError, utils
 
diff --git a/tests/sources/remote.py b/tests/sources/remote.py
index 416d2d5..7dc694f 100644
--- a/tests/sources/remote.py
+++ b/tests/sources/remote.py
@@ -3,12 +3,13 @@
 
 import os
 import stat
+
 import pytest
 
 from buildstream import utils
-from buildstream.testing import ErrorDomain
-from buildstream.testing import generate_project
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import ErrorDomain, generate_project
+
 from tests.testutils.file_server import create_file_server
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "remote",)
diff --git a/tests/sources/tar.py b/tests/sources/tar.py
index ed662dc..9ccedcb 100644
--- a/tests/sources/tar.py
+++ b/tests/sources/tar.py
@@ -2,20 +2,22 @@
 # pylint: disable=redefined-outer-name
 
 import os
-from shutil import copyfile
 import subprocess
 import tarfile
 import tempfile
 import urllib.parse
+from shutil import copyfile
 
 import pytest
 
 from buildstream import utils
 from buildstream.exceptions import ErrorDomain
-from buildstream.testing import generate_project, generate_element
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import generate_element, generate_project
 from buildstream.testing._utils.site import HAVE_LZIP
+
 from tests.testutils.file_server import create_file_server
+
 from . import list_dir_contents
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "tar",)
diff --git a/tests/sources/variables.py b/tests/sources/variables.py
index 3e9a08f..26e9756 100644
--- a/tests/sources/variables.py
+++ b/tests/sources/variables.py
@@ -8,7 +8,6 @@ import pytest
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
 
-
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "variables")
 
 
diff --git a/tests/sources/zip.py b/tests/sources/zip.py
index 201271f..42ff1ac 100644
--- a/tests/sources/zip.py
+++ b/tests/sources/zip.py
@@ -7,9 +7,11 @@ import zipfile
 import pytest
 
 from buildstream.exceptions import ErrorDomain
-from buildstream.testing import generate_project
 from buildstream.testing import cli  # pylint: disable=unused-import
+from buildstream.testing import generate_project
+
 from tests.testutils.file_server import create_file_server
+
 from . import list_dir_contents
 
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "zip",)
diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py
index 9642ddf..f582556 100644
--- a/tests/testutils/__init__.py
+++ b/tests/testutils/__init__.py
@@ -23,10 +23,10 @@
 #           William Salmon <wi...@codethink.co.uk>
 #
 
-from .artifactshare import create_artifact_share, create_split_share, assert_shared, assert_not_shared
+from .artifactshare import assert_not_shared, assert_shared, create_artifact_share, create_split_share
 from .context import dummy_context
 from .element_generators import create_element_size, update_element_size
 from .junction import generate_junction
-from .runner_integration import wait_for_cache_granularity
-from .python_repo import setup_pypi_repo
 from .platform import override_platform_uname
+from .python_repo import setup_pypi_repo
+from .runner_integration import wait_for_cache_granularity
diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py
index a15a7c2..fab2b73 100644
--- a/tests/testutils/artifactshare.py
+++ b/tests/testutils/artifactshare.py
@@ -3,8 +3,8 @@ import shutil
 import signal
 import sys
 from collections import namedtuple
-from contextlib import ExitStack, contextmanager
 from concurrent import futures
+from contextlib import ExitStack, contextmanager
 from multiprocessing import Process, Queue
 
 import grpc
diff --git a/tests/testutils/context.py b/tests/testutils/context.py
index 821adef..69d999e 100644
--- a/tests/testutils/context.py
+++ b/tests/testutils/context.py
@@ -15,9 +15,8 @@
 #  License along with this library. If not, see <http://www.gnu.org/licenses/>.
 
 import os
-
-from types import MethodType
 from contextlib import contextmanager
+from types import MethodType
 
 from buildstream._context import Context
 
diff --git a/tests/testutils/element_generators.py b/tests/testutils/element_generators.py
index 6da465a..441a59f 100644
--- a/tests/testutils/element_generators.py
+++ b/tests/testutils/element_generators.py
@@ -1,7 +1,6 @@
 import os
 
-from buildstream import _yaml
-from buildstream import utils
+from buildstream import _yaml, utils
 from buildstream.testing import create_repo
 
 
diff --git a/tests/testutils/http_server.py b/tests/testutils/http_server.py
index 8591159..d27bfb0 100644
--- a/tests/testutils/http_server.py
+++ b/tests/testutils/http_server.py
@@ -1,9 +1,9 @@
+import base64
+import html
 import multiprocessing
 import os
 import posixpath
-import html
-import base64
-from http.server import SimpleHTTPRequestHandler, HTTPServer, HTTPStatus
+from http.server import HTTPServer, HTTPStatus, SimpleHTTPRequestHandler
 
 
 class Unauthorized(Exception):
diff --git a/tests/testutils/platform.py b/tests/testutils/platform.py
index f8faf28..d42db41 100644
--- a/tests/testutils/platform.py
+++ b/tests/testutils/platform.py
@@ -17,8 +17,8 @@
 #  Authors:
 #        Angelos Evripiotis <je...@bloomberg.net>
 
-from contextlib import contextmanager
 import platform
+from contextlib import contextmanager
 
 
 # override_platform_uname()
diff --git a/tests/testutils/python_repo.py b/tests/testutils/python_repo.py
index 07efa37..3666ffc 100644
--- a/tests/testutils/python_repo.py
+++ b/tests/testutils/python_repo.py
@@ -6,7 +6,6 @@ import sys
 
 import pytest
 
-
 SETUP_TEMPLATE = """\
 from setuptools import setup
 
diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py
index b698341..e4f6388 100644
--- a/tests/testutils/repo/bzr.py
+++ b/tests/testutils/repo/bzr.py
@@ -1,5 +1,6 @@
 import os
 import subprocess
+
 import pytest
 
 from buildstream.testing import Repo
diff --git a/tests/testutils/repo/tar.py b/tests/testutils/repo/tar.py
index 3eb9d89..c2228be 100644
--- a/tests/testutils/repo/tar.py
+++ b/tests/testutils/repo/tar.py
@@ -1,9 +1,8 @@
 import os
 import tarfile
 
-from buildstream.utils import sha256sum
-
 from buildstream.testing import Repo
+from buildstream.utils import sha256sum
 
 
 class Tar(Repo):
diff --git a/tests/testutils/repo/zip.py b/tests/testutils/repo/zip.py
index 38419e6..462e9c3 100644
--- a/tests/testutils/repo/zip.py
+++ b/tests/testutils/repo/zip.py
@@ -1,9 +1,8 @@
 import os
 import zipfile
 
-from buildstream.utils import sha256sum
-
 from buildstream.testing import Repo
+from buildstream.utils import sha256sum
 
 
 class Zip(Repo):
diff --git a/tests/testutils/setuptools.py b/tests/testutils/setuptools.py
index 0f7f30f..9c000a0 100644
--- a/tests/testutils/setuptools.py
+++ b/tests/testutils/setuptools.py
@@ -1,6 +1,7 @@
 import os
-import pytest
+
 import pkg_resources
+import pytest
 
 
 # A mock setuptools dist object.
diff --git a/tox.ini b/tox.ini
index f714629..1f4b230 100644
--- a/tox.ini
+++ b/tox.ini
@@ -122,8 +122,10 @@ setenv =
 skip_install = True
 deps =
     black==19.10b0
+    isort
 commands =
-    black {posargs: src tests doc/source/conf.py setup.py}
+    isort --apply --recursive --atomic {posargs: src tests doc/source/conf.py setup.py}
+    #black {posargs: src tests doc/source/conf.py setup.py}
 
 #
 # Code format checkers
@@ -132,7 +134,9 @@ commands =
 skip_install = True
 deps =
     black==19.10b0
+    isort
 commands =
+    isort --check-only --recursive --diff {posargs: src tests doc/source/conf.py setup.py}
     black --check --diff {posargs: src tests doc/source/conf.py setup.py}
 
 #