Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ confidence=
# be nice, but too much work atm.
#
# 3) Messages related to code formatting
# Since we use Black to format code automatically, there's no need for
# Since we use Ruff to format code automatically, there's no need for
# pylint to also check for those things.
#

Expand Down Expand Up @@ -146,7 +146,7 @@ disable=,
unused-private-member,

##################################################
# Formatting-related messages, enforced by Black #
# Formatting-related messages, enforced by Ruff #
##################################################

line-too-long,
Expand Down
2 changes: 1 addition & 1 deletion doc/source/hacking/coding_guidelines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Approximate PEP-8 Style
~~~~~~~~~~~~~~~~~~~~~~~
Python coding style for BuildStream is approximately `pep8 <https://www.python.org/dev/peps/pep-0008/>`_.

The coding style is automatically enforced by `black <https://black.readthedocs.io/en/stable/>`_.
The coding style is automatically enforced by `ruff <https://docs.astral.sh/ruff/>`_.

Formatting will be checked automatically when running the testsuite on CI. For
details on how to format your code locally, see :ref:`formatting code <contributing_formatting_code>`.
Expand Down
2 changes: 1 addition & 1 deletion doc/source/hacking/using_the_testsuite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ consists of running the ``pylint`` tool, run the following::
Formatting code
~~~~~~~~~~~~~~~
Similar to linting, code formatting is also done via a ``tox`` environment. To
format the code using the ``black`` tool, run the following::
format the code using the ``ruff`` tool, run the following::

tox -e format

Expand Down
23 changes: 6 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ requires = [
]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 119
exclude = '''
(
/(
\.eggs
| \.git
| \.mypy_cache
| \.tox
| _build
| build
| dist
)/
| src/buildstream/_protos
)
'''

[tool.cibuildwheel]
build-frontend = "build"
environment = { BST_BUNDLE_BUILDBOX = "1" }
Expand All @@ -64,3 +47,9 @@ skip = [
# The prebuilt BuildBox binaries link against GLibc so will work on manylinux but not musllinux
"*-musllinux_*",
]

[tool.ruff]
extend-exclude = [
"src/buildstream/_protos",
]
line-length = 119
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def list_buildbox_binaries():
if missing_binaries:
paths_text = "\n".join([" * {}".format(path) for path in missing_binaries])
print(
"Expected BuildBox binaries were not found. "
"Set BST_BUNDLE_BUILDBOX=0 or provide:\n\n"
"{}\n".format(paths_text),
"Expected BuildBox binaries were not found. Set BST_BUNDLE_BUILDBOX=0 or provide:\n\n{}\n".format(
paths_text
),
file=sys.stderr,
)
raise SystemExit(1)
Expand Down
1 change: 0 additions & 1 deletion src/buildstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os

if "_BST_COMPLETION" not in os.environ:

# Special sauce to get the version from versioneer
from ._version import get_versions

Expand Down
16 changes: 1 addition & 15 deletions src/buildstream/_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .sandbox._config import SandboxConfig
from ._variables import Variables


# An Artifact class to abstract artifact operations
# from the Element class
#
Expand All @@ -48,7 +49,6 @@
# weak_key (str): The elements weak cache key
#
class Artifact:

version = 2

def __init__(self, element, context, *, strong_key=None, strict_key=None, weak_key=None):
Expand Down Expand Up @@ -214,7 +214,6 @@ def cache(
environment,
sandboxconfig,
):

context = self._context
element = self._element
size = 0
Expand Down Expand Up @@ -336,7 +335,6 @@ def cache(
# if a buildroot is present, not its contents.
#
def cached_buildroot(self):

buildroot_digest = self._get_field_digest("buildroot")
if buildroot_digest:
return self._cas.contains_directory(buildroot_digest)
Expand All @@ -352,7 +350,6 @@ def cached_buildroot(self):
# (bool): True if artifact was created with buildroot
#
def buildroot_exists(self):

artifact = self._get_proto()
return bool(str(artifact.buildroot))

Expand All @@ -368,7 +365,6 @@ def buildroot_exists(self):
# if a buildtree is present, not its contents.
#
def cached_buildtree(self):

buildtree_digest = self._get_field_digest("buildtree")
if buildtree_digest:
return self._cas.contains_directory(buildtree_digest)
Expand All @@ -384,7 +380,6 @@ def cached_buildtree(self):
# (bool): True if artifact was created with buildtree
#
def buildtree_exists(self):

artifact = self._get_proto()
return bool(str(artifact.buildtree))

Expand All @@ -397,7 +392,6 @@ def buildtree_exists(self):
# are not available.
#
def cached_sources(self):

sources_digest = self._get_field_digest("sources")
if sources_digest:
return self._cas.contains_directory(sources_digest)
Expand All @@ -412,7 +406,6 @@ def cached_sources(self):
# (dict): The artifacts cached public data
#
def load_public_data(self):

# Load the public data from the artifact
artifact = self._get_proto()
with self._cas.open(artifact.public_data) as meta_file:
Expand All @@ -429,7 +422,6 @@ def load_public_data(self):
# The stored SandboxConfig object
#
def load_sandbox_config(self) -> SandboxConfig:

# Load the sandbox data from the artifact
artifact = self._get_proto()
meta_file = self._cas.objpath(artifact.low_diversity_meta)
Expand All @@ -449,7 +441,6 @@ def load_sandbox_config(self) -> SandboxConfig:
# The environment variables
#
def load_environment(self) -> Dict[str, str]:

# Load the sandbox data from the artifact
artifact = self._get_proto()
meta_file = self._cas.objpath(artifact.low_diversity_meta)
Expand All @@ -469,7 +460,6 @@ def load_environment(self) -> Dict[str, str]:
# The element variables
#
def load_variables(self) -> Variables:

# Load the sandbox data from the artifact
artifact = self._get_proto()
meta_file = self._cas.objpath(artifact.high_diversity_meta)
Expand All @@ -489,7 +479,6 @@ def load_variables(self) -> Variables:
# (str): Detailed description of the result
#
def load_build_result(self):

artifact = self._get_proto()
build_result = (artifact.build_success, artifact.build_error, artifact.build_error_details)

Expand All @@ -505,7 +494,6 @@ def load_build_result(self):
# The weak key
#
def get_metadata_keys(self) -> Tuple[str, str, str]:

if self._metadata_keys is not None:
return self._metadata_keys

Expand All @@ -528,7 +516,6 @@ def get_metadata_keys(self) -> Tuple[str, str, str]:
# (bool): Whether the given artifact was workspaced
#
def get_metadata_workspaced(self):

if self._metadata_workspaced is not None:
return self._metadata_workspaced

Expand All @@ -547,7 +534,6 @@ def get_metadata_workspaced(self):
# (list): List of which dependencies are workspaced
#
def get_metadata_workspaced_dependencies(self):

if self._metadata_workspaced_dependencies is not None:
return self._metadata_workspaced_dependencies

Expand Down
2 changes: 0 additions & 2 deletions src/buildstream/_artifactcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def link_key(self, element, oldkey, newkey):
# missing_blobs (list): The Digests of the blobs to fetch
#
def fetch_missing_blobs(self, project, missing_blobs):

index_remotes, _ = self.get_remotes(project.name, False)
for remote in index_remotes:
if not missing_blobs:
Expand Down Expand Up @@ -389,7 +388,6 @@ def _push_artifact_blobs(self, artifact, artifact_digest, remote):
# artifact already existing.
#
def _push_artifact_proto(self, element, artifact, artifact_digest, remote):

artifact_proto = artifact._get_proto()

keys = list(utils._deduplicate([artifact_proto.strong_key, artifact_proto.weak_key]))
Expand Down
2 changes: 0 additions & 2 deletions src/buildstream/_artifactelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
# ref (str): The artifact ref
#
class ArtifactElement(Element):

# A hash of ArtifactElement by ref
__instantiated_artifacts: Dict[str, "ArtifactElement"] = {}

Expand Down Expand Up @@ -70,7 +69,6 @@ def __init__(self, context, ref):
#
@classmethod
def new_from_artifact_name(cls, artifact_name: str, context: "Context", task: Optional["Task"] = None):

# Initial lookup for already loaded artifact.
with suppress(KeyError):
return cls.__instantiated_artifacts[artifact_name]
Expand Down
2 changes: 0 additions & 2 deletions src/buildstream/_artifactproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
# project_name: The name of this project
#
class ArtifactProject(Project):

__loaded_artifact_projects = {} # type: Dict[str, ArtifactProject]

def __init__(self, project_name: str, context: Context):

#
# Chain up to the Project constructor, and allow it to initialize
# without loading anything
Expand Down
3 changes: 0 additions & 3 deletions src/buildstream/_assetcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ def __init__(self, context):
# Release resources used by AssetCache.
#
def release_resources(self):

# Close all remotes and their gRPC channels
for remote in self._remotes.values():
if remote.index:
Expand All @@ -338,7 +337,6 @@ def release_resources(self):
# project_specs: List of specs for each project
#
def setup_remotes(self, specs: Iterable[RemoteSpec], project_specs: Dict[str, List[RemoteSpec]]):

# Hold on to the project specs
self._project_specs = project_specs

Expand Down Expand Up @@ -387,7 +385,6 @@ def get_remotes(self, project_name: str, push: bool) -> Tuple[List[AssetRemote],
index_remotes = []
storage_remotes = []
for spec in project_specs:

if push and not spec.push:
continue

Expand Down
4 changes: 2 additions & 2 deletions src/buildstream/_cas/casdprocessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
*,
reserved=None,
low_watermark=None,
local_jobs=None
local_jobs=None,
):
os.makedirs(path, exist_ok=True)

Expand Down Expand Up @@ -159,7 +159,7 @@ def __init__(
stdout=logfile_fp,
stderr=subprocess.STDOUT,
env=self.__buildbox_casd_env(),
**process_group_kwargs
**process_group_kwargs,
)

self._casd_channel = None
Expand Down
1 change: 0 additions & 1 deletion src/buildstream/_cas/casremote.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def _configure_protocols(self):
# (CASRemoteError): if there was an error
#
def push_message(self, message):

message_buffer = message.SerializeToString()

self.init()
Expand Down
3 changes: 0 additions & 3 deletions src/buildstream/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def new_from_node(cls, node: MappingNode) -> "_CacheConfig":
#
class Context:
def __init__(self, *, use_casd: bool = True) -> None:

# Whether we are running as part of a test suite. This is only relevant
# for developing BuildStream itself.
self.is_running_in_test_suite: bool = "BST_TEST_SUITE" in os.environ
Expand Down Expand Up @@ -601,7 +600,6 @@ def initialize_remotes(
ignore_project_artifact_remotes: bool = False,
ignore_project_source_remotes: bool = False,
) -> None:

# Ensure all projects are fully loaded.
for project in self._projects:
project.ensure_fully_loaded()
Expand Down Expand Up @@ -782,7 +780,6 @@ def _resolve_specs_for_project(
override_key: str,
project_attribute: str,
) -> List[RemoteSpec]:

# Early return if the CLI is taking full control
if cli_override and cli_remotes:
return list(cli_remotes)
Expand Down
7 changes: 3 additions & 4 deletions src/buildstream/_elementproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ def stage_artifact(
action: str = OverlapAction.WARNING,
include: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
orphans: bool = True
orphans: bool = True,
) -> FileListResult:

owner = cast("Element", self._owner)
element = cast("Element", self._plugin)

Expand All @@ -122,7 +121,7 @@ def stage_dependency_artifacts(
action: str = OverlapAction.WARNING,
include: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
orphans: bool = True
orphans: bool = True,
) -> None:
#
# Same approach used here as in Element.dependencies()
Expand Down Expand Up @@ -171,7 +170,7 @@ def _stage_artifact(
include: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
orphans: bool = True,
owner: Optional["Element"] = None
owner: Optional["Element"] = None,
) -> FileListResult:
owner = cast("Element", self._owner)
element = cast("Element", self._plugin)
Expand Down
7 changes: 4 additions & 3 deletions src/buildstream/_elementsources.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

# pylint: enable=cyclic-import


# An ElementSources object represents the combined sources of an element.
class ElementSources:
def __init__(self, context: Context, project: "Project", plugin: Plugin):

self._context = context
self._project = project
self._plugin = plugin
Expand Down Expand Up @@ -396,8 +396,9 @@ def preflight(self):
from .element import ElementError # pylint: disable=cyclic-import

raise ElementError(
"{}: {} cannot be the first source of an element "
"as it requires access to previous sources".format(self, self._sources[0])
"{}: {} cannot be the first source of an element as it requires access to previous sources".format(
self, self._sources[0]
)
)

# Preflight the sources
Expand Down
1 change: 0 additions & 1 deletion src/buildstream/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ def __init__(self, message, *, detail=None, reason=None):
#
class StreamError(BstError):
def __init__(self, message=None, *, detail=None, reason=None, terminated=False):

# The empty string should never appear to a user,
# this only allows us to treat this internal error as
# a BstError from the frontend.
Expand Down
Loading