Skip to content

Commit

Permalink
Merge pull request #2183 from SUSE/ruff_2025
Browse files Browse the repository at this point in the history
Switch to Ruff format of 2025
  • Loading branch information
dcermak authored Jan 13, 2025
2 parents 1b8328d + b640bf0 commit a13dcb1
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 64 deletions.
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ scratch-build-bot = "staging.bot:main"
update-versions = "bci_build.package.versions:run_version_update"

[tool.poetry.group.dev.dependencies]
ruff = ">=0.1.14"
ruff = ">=0.9.0"
Sphinx = ">=4.4"
pytest = ">=7.1"
types-aiofiles = ">=22.1"
Expand Down
10 changes: 4 additions & 6 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,7 @@ def kiwi_derived_from_entry(self) -> str:
":", "#"
)
return f' derived_from="obsrepositories:/{repo}"'
return (
f" derived_from=\"obsrepositories:/{self._from_image.replace(':', '#')}\""
)
return f' derived_from="obsrepositories:/{self._from_image.replace(":", "#")}"'

@property
def packages(self) -> str:
Expand Down Expand Up @@ -1102,9 +1100,9 @@ async def write_file_to_dest(fname: str, contents: str | bytes) -> None:
files.append("config.sh")

else:
assert (
False
), f"got an unexpected build_recipe_type: '{self.build_recipe_type}'"
assert False, (
f"got an unexpected build_recipe_type: '{self.build_recipe_type}'"
)

if self.build_flavor:
dfile = "Dockerfile"
Expand Down
2 changes: 1 addition & 1 deletion src/bci_build/package/appcontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
"extra_files": _NGINX_FILES,
"support_level": SupportLevel.L3,
"exposes_ports": [TCP(80)],
"custom_end": f"""{ version_check_lines }
"custom_end": f"""{version_check_lines}
{DOCKERFILE_RUN} mkdir /docker-entrypoint.d
COPY [1-3]0-*.sh /docker-entrypoint.d/
COPY docker-entrypoint.sh /usr/local/bin
Expand Down
2 changes: 1 addition & 1 deletion src/bci_build/package/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def generate_package_version_check(

return f"""# sanity check that the version from the tag is equal to the version of {pkg_name} that we expect
{DOCKERFILE_RUN} \\
[ "$(rpm{' --root /target' if use_target else ''} -q --qf '%{{version}}' {pkg_name} | \\
[ "$(rpm{" --root /target" if use_target else ""} -q --qf '%{{version}}' {pkg_name} | \\
cut -d '.' -f -{cut_count})" = "{pkg_version}" ]"""


Expand Down
6 changes: 3 additions & 3 deletions src/bci_build/package/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
# ensure that the **latest** rust version is the last one!
_RUST_VERSIONS = ["1.82", "1.83"]

assert (
len(_RUST_VERSIONS) == 2
), "Only two versions of rust must be supported at the same time"
assert len(_RUST_VERSIONS) == 2, (
"Only two versions of rust must be supported at the same time"
)

assert packaging.version.parse(_RUST_VERSIONS[0]) < packaging.version.parse(
_RUST_VERSIONS[1]
Expand Down
2 changes: 1 addition & 1 deletion src/bci_build/package/spack.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
/root/.spack/modules.yaml \
&& rm -rf /root/*.* /run/nologin
{generate_package_version_check('spack', spack_pkg_version, ParseVersion.PATCH)}
{generate_package_version_check("spack", spack_pkg_version, ParseVersion.PATCH)}
WORKDIR /root
SHELL ["docker-shell"]
Expand Down
16 changes: 9 additions & 7 deletions src/dotnet/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def __post_init__(self):
"8.0": datetime.date(2026, 11, 10),
"9.0": datetime.date(2026, 5, 12),
}.get(str(self.tag_version))
assert (
self.supported_until
), f".Net version missing in lifecycle information: {self.tag_version}"
assert self.supported_until, (
f".Net version missing in lifecycle information: {self.tag_version}"
)

self.extra_files = {
"dotnet-host.check": f"requires:dotnet-host < {ver.major}.{ver.minor + 1}",
Expand Down Expand Up @@ -227,9 +227,9 @@ def _fetch_ordinary_package(self, pkg: str | Package) -> list[RpmPackage]:
pkgs.append(RpmPackage.from_dnf_package(pkg=pkgs_for_arch[0], arch=arch))

if isinstance(pkg, str):
assert len(pkgs) == len(
self.exclusive_arch
), "Must find one package per architecture"
assert len(pkgs) == len(self.exclusive_arch), (
"Must find one package per architecture"
)

return pkgs

Expand Down Expand Up @@ -330,7 +330,9 @@ def prepare_template(self) -> None:
pkgs = self._fetch_packages()
self.version = self._guess_version_from_pkglist(pkgs)
if self.version:
assert not self.additional_versions, f"additional_versions property must be unset, but got {self.additional_versions}"
assert not self.additional_versions, (
f"additional_versions property must be unset, but got {self.additional_versions}"
)

self.custom_end = CUSTOM_END_TEMPLATE.render(
image=self,
Expand Down
19 changes: 10 additions & 9 deletions src/staging/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,11 @@ def from_github_comment(comment_text: str, osc_username: str) -> "StagingBot":
osc_username=osc_username,
)

assert (
bot.staging_project_name
== (prj := prj_markdown_link.split("]")[0].replace("[", ""))
), f"Mismatch between the constructed project name ({bot.staging_project_name}) and the project name from the comment ({prj})"
assert bot.staging_project_name == (
prj := prj_markdown_link.split("]")[0].replace("[", "")
), (
f"Mismatch between the constructed project name ({bot.staging_project_name}) and the project name from the comment ({prj})"
)
return bot

@staticmethod
Expand Down Expand Up @@ -554,8 +555,8 @@ async def write_env_file(self):
DEPLOYMENT_BRANCH_NAME={self.deployment_branch_name}
PROJECT_NAME={self.staging_project_name}
PROJECT_URL={self.staging_project_url}
REPOSITORIES={','.join(self.repositories)}
PACKAGES={','.join(self.package_names) if self.package_names else None}
REPOSITORIES={",".join(self.repositories)}
PACKAGES={",".join(self.package_names) if self.package_names else None}
"""
)

Expand Down Expand Up @@ -803,9 +804,9 @@ def _get_changed_packages_by_commit(self, commit: str | git.Commit) -> list[str]
for diff in git_commit.diff(f"origin/{self.deployment_branch_name}"):
# no idea how this could happen, but in theory the diff mode can be
# `C` for conflict => abort if that's the case
assert (
diff.a_mode != "C" and diff.b_mode != "C"
), f"diff must not be a conflict, but got {diff=}"
assert diff.a_mode != "C" and diff.b_mode != "C", (
f"diff must not be a conflict, but got {diff=}"
)

if (
(a_path := os.path.split(diff.a_path))
Expand Down
29 changes: 14 additions & 15 deletions src/staging/build_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class RepositoryBuildResult:

@staticmethod
def _from_result(result: ET.Element) -> "RepositoryBuildResult":
assert (
result.tag == "result"
), f"Invalid element passed, expected '<result>' but got: {ET.tostring(result).decode()}"
assert result.tag == "result", (
f"Invalid element passed, expected '<result>' but got: {ET.tostring(result).decode()}"
)
attr = result.attrib
for attr_name in ("project", "repository", "arch", "code", "state"):
if attr_name not in attr:
Expand Down Expand Up @@ -163,16 +163,15 @@ def is_build_failed(build_results: list[RepositoryBuildResult]) -> bool:
)

for pkg_res in build_res.packages:
assert (
pkg_res.code
in (
PackageStatusCode.EXCLUDED,
PackageStatusCode.FAILED,
PackageStatusCode.SUCCEEDED,
PackageStatusCode.UNRESOLVABLE,
PackageStatusCode.DISABLED,
)
), f"package {pkg_res.name} (from repository {build_res.repository} for {build_res.project} and {build_res.arch}) has unfinished state {pkg_res.code}"
assert pkg_res.code in (
PackageStatusCode.EXCLUDED,
PackageStatusCode.FAILED,
PackageStatusCode.SUCCEEDED,
PackageStatusCode.UNRESOLVABLE,
PackageStatusCode.DISABLED,
), (
f"package {pkg_res.name} (from repository {build_res.repository} for {build_res.project} and {build_res.arch}) has unfinished state {pkg_res.code}"
)

if pkg_res.code in (
PackageStatusCode.FAILED,
Expand Down Expand Up @@ -217,8 +216,8 @@ def render_as_markdown(
no_detail = all(not pkg.detail_message for pkg in repo_res.packages)

res += f"""Build results:
package name | status {'' if no_detail else '| detail '}| build log
-------------|--------{'' if no_detail else '|--------'}|----------
package name | status {"" if no_detail else "| detail "}| build log
-------------|--------{"" if no_detail else "|--------"}|----------
"""
for package_res in repo_res.packages:
if no_detail:
Expand Down

0 comments on commit a13dcb1

Please sign in to comment.