diff --git a/.ci/lib/apkbuild_linting.py b/.ci/lib/apkbuild_linting.py index d16c2e78c..c14050a91 100755 --- a/.ci/lib/apkbuild_linting.py +++ b/.ci/lib/apkbuild_linting.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later -import common import os -import sys import subprocess -import tomllib +import sys +import common +import tomllib custom_valid_options = [ "!pmb:crossdirect", @@ -63,7 +63,7 @@ if __name__ == "__main__": sys.exit(0) print("Running apkbuild-lint...") - print("") + print() ret = 0 for apkbuild in apkbuilds_filtered: @@ -73,7 +73,7 @@ if __name__ == "__main__": except subprocess.CalledProcessError as exception: ret = exception.returncode - print("") + print() if ret == 0: print("Success") diff --git a/.ci/lib/build_changed_aports.py b/.ci/lib/build_changed_aports.py index 80641b486..e7cc01186 100755 --- a/.ci/lib/build_changed_aports.py +++ b/.ci/lib/build_changed_aports.py @@ -1,18 +1,18 @@ #!/usr/bin/env python3 # Copyright 2021 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -import sys import os import pathlib +import sys # Same dir import common # pmbootstrap import pmb.core +import pmb.helpers.pmaports import pmb.parse import pmb.parse._apkbuild -import pmb.helpers.pmaports from pmb.core.arch import Arch from pmb.core.context import get_context diff --git a/.ci/lib/check_changed_versions.py b/.ci/lib/check_changed_versions.py index 056027a84..55b141aa4 100755 --- a/.ci/lib/check_changed_versions.py +++ b/.ci/lib/check_changed_versions.py @@ -4,19 +4,20 @@ import os.path import pathlib -import tempfile -import sys import subprocess +import sys +import tempfile # Same dir import common +import pmb.helpers.logging # pmbootstrap import pmb.parse import pmb.parse.version -import pmb.helpers.logging from pmb.core.context import get_context + def get_package_contents(package, revision, check=True): # Redirect stderr to /dev/null, so git doesn't complain about files not # existing in upstream branch for new packages diff --git a/.ci/lib/check_devices_in_wiki.py b/.ci/lib/check_devices_in_wiki.py index ee81e1149..a418e34af 100755 --- a/.ci/lib/check_devices_in_wiki.py +++ b/.ci/lib/check_devices_in_wiki.py @@ -2,14 +2,15 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -from pathlib import Path import argparse import sys import urllib.request +from pathlib import Path # Same dir import common + def get_devices() -> list[str]: """:returns: list of all devices""" ret = [] @@ -21,8 +22,7 @@ def get_devices() -> list[str]: # devices that have a working mainline kernel. Those are usually # unmaintained and therefore might not appear in the wiki. However, # the main device should be documented (remove the -downstream suffix). - if device.endswith('-downstream'): - device = device[:-len('-downstream')] + device = device.removesuffix('-downstream') ret.append(device) return sorted(ret) @@ -120,21 +120,21 @@ def main() -> int: if error: print("*** Wiki check failed!") print("Thank you for porting postmarketOS to a new device! \\o/") - print("") + print() print("Now it's time to add some documentation:") print("1) Create a device specific wiki page as described here:") print(" https://wiki.postmarketos.org/wiki/Help:Device_Page") print("2) Set 'booting = yes' in the infobox of your device page.") print("3) Run these tests again with an empty commit in your MR:") print(" $ git commit --allow-empty -m 'run tests again'") - print("") + print() print("Please take the time to do these steps. It will make your") print("precious porting efforts visible for others, and allow them") print("not only to use what you have created, but also to build upon") print("it more easily. Many times one person did a port with basic") print("functionality, and then someone else jumped in and") print("contributed major new features.") - print("") + print() print("NOTE: if you renamed a device in pmaports, rename it in the") print("wiki as well and make sure to add it here:") print("https://postmarketos.org/renamed") diff --git a/.ci/lib/common.py b/.ci/lib/common.py index 663e9a3ef..8d9771f74 100755 --- a/.ci/lib/common.py +++ b/.ci/lib/common.py @@ -42,7 +42,7 @@ def all_committed_by_merge_bot(): def run_pmbootstrap(parameters): """ Run pmbootstrap with the pmaports dir as --aports """ cmd = ["pmbootstrap", "--aports", get_pmaports_dir()] + parameters - subprocess.run(cmd, universal_newlines=True, check=True) + subprocess.run(cmd, text=True, check=True) @cache diff --git a/.ci/lib/deviceinfo_linting.py b/.ci/lib/deviceinfo_linting.py index 2b51b5522..a8bf85e64 100755 --- a/.ci/lib/deviceinfo_linting.py +++ b/.ci/lib/deviceinfo_linting.py @@ -2,12 +2,13 @@ # Copyright 2025 Stefan Hansson # SPDX-License-Identifier: GPL-3.0-or-later -import common import glob import os.path import subprocess import sys +import common + if __name__ == "__main__": if common.commit_message_has_string("[ci:skip-dint]"): print("WARNING: not linting deviceinfo files ([ci:skip-dint])") diff --git a/.ci/lib/generate_build_jobs.py b/.ci/lib/generate_build_jobs.py index 72eebd6e5..dce5bf3e9 100755 --- a/.ci/lib/generate_build_jobs.py +++ b/.ci/lib/generate_build_jobs.py @@ -3,23 +3,22 @@ # SPDX-License-Identifier: GPL-3.0-or-later import argparse +import sys +import traceback from functools import cached_property from pathlib import Path from typing import Self -import sys -import traceback - -from jinja2 import Template -import pmb.parse -from pmb.parse.deviceinfo import Deviceinfo -from pmb.types import Apkbuild -import pmb.helpers.devices -import pmb.helpers.logging -import pmb.helpers.package -from pmb.core.arch import Arch # Same dir import common +import pmb.helpers.devices +import pmb.helpers.logging +import pmb.helpers.package +import pmb.parse +from jinja2 import Template +from pmb.core.arch import Arch +from pmb.parse.deviceinfo import Deviceinfo +from pmb.types import Apkbuild class Device: diff --git a/.ci/lib/kconfig.py b/.ci/lib/kconfig.py index 3eae5eab7..e6fee1c71 100755 --- a/.ci/lib/kconfig.py +++ b/.ci/lib/kconfig.py @@ -29,46 +29,46 @@ def check_kconfig_all(): def show_error(last_failed): - print("") + print() print("---") - print("") + print() print("Please adjust your kernel config. This is required for getting your" " patch merged.") - print("") + print() print("Edit your kernel config:") print(f" pmbootstrap kconfig edit {last_failed}") - print("") + print() print("Test this kernel config again:") print(f" pmbootstrap kconfig check {last_failed}") - print("") + print() print("Run this check again (on all kernels you modified):") print(" pmbootstrap ci kconfig") - print("") + print() print("---") - print("") + print() def show_error_all(): - print("") + print() print("---") - print("") + print() print("Please adjust the failed kernel configs. This is required for") print("getting your patch merged.") - print("") + print() print("If a kernel in the testing category failed, and fixing is too much") print("effort, remove 'pmb:kconfigcheck-community' from the APKBUILD.") - print("") + print() print("Edit a kernel config:") print(" pmbootstrap kconfig edit ") - print("") + print() print("Test a specific kernel config again:") print(" pmbootstrap kconfig check ") - print("") + print() print("Run this check again (on all kernels you modified):") print(" pmbootstrap ci kconfig") - print("") + print() print("---") - print("") + print() if __name__ == "__main__": diff --git a/.ci/testcases/conftest.py b/.ci/testcases/conftest.py index 0f3ecaf5a..70474a55f 100644 --- a/.ci/testcases/conftest.py +++ b/.ci/testcases/conftest.py @@ -2,13 +2,15 @@ # Copyright 2021 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later +import os from pathlib import Path + +import pmb.config import pmb.parse +import pytest from pmb.helpers.args import init as init_args from pmb.types import PmbArgs -import pmb.config -import pytest -import os + @pytest.fixture(scope="session", autouse=True) def args(request): diff --git a/.ci/testcases/test_device.py b/.ci/testcases/test_device.py index 35d2a8993..1133d44b7 100644 --- a/.ci/testcases/test_device.py +++ b/.ci/testcases/test_device.py @@ -5,8 +5,8 @@ import pmb.parse import pmb.parse._apkbuild -from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_iglob from pmb.core.arch import Arch +from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_iglob # Don't complain if these nicknames are the only maintainers of an APKBUILD, # because they are actually a group of people diff --git a/.ci/testcases/test_source.py b/.ci/testcases/test_source.py index 8c2361775..0a856627e 100644 --- a/.ci/testcases/test_source.py +++ b/.ci/testcases/test_source.py @@ -7,10 +7,10 @@ import glob import logging import os +import pmb.helpers.repo import pmb.parse import pmb.parse._apkbuild import pmb.parse.apkindex -import pmb.helpers.repo from pmb.core.pkgrepo import pkgrepo_iter_package_dirs, pkgrepo_relative_path @@ -30,7 +30,7 @@ def parse_source_from_checksums(apkbuild_path): ret = {} with open(apkbuild_path, encoding="utf-8") as handle: - for line in handle.readlines(): + for line in handle: # Find start if not in_block: if line.startswith(start): @@ -51,12 +51,10 @@ def parse_source_from_checksums(apkbuild_path): f" 'pmbootstrap checksum': {apkbuild_path}") # Cut off 'sha512sums="' if the first checksum is in that line - if checksum.startswith(start): - checksum = checksum[len(start):] + checksum = checksum.removeprefix(start) # Find end - if filename.endswith('"'): - filename = filename[:-1] + filename = filename.removesuffix('"') ret[filename] = checksum return ret diff --git a/.ci/testcases/test_systemd.py b/.ci/testcases/test_systemd.py index e3b2f0474..743148089 100644 --- a/.ci/testcases/test_systemd.py +++ b/.ci/testcases/test_systemd.py @@ -3,10 +3,10 @@ # SPDX-License-Identifier: GPL-3.0-or-later import logging import os +from pathlib import Path import pmb.parse from pmb.core.context import get_context -from pathlib import Path def test_systemd_stage0_version():