ci: automatic ruff checks for ruff 0.16.0

run ruff check --fix with ruff 0.16.0, review, and commit

Signed-off-by: Pablo Correa Gómez <pabloyoyoista@postmarketos.org>
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/9363>
This commit is contained in:
Pablo Correa Gómez
2026-08-12 05:39:43 +00:00
parent bec46b5311
commit 47748f6158
12 changed files with 56 additions and 55 deletions
+5 -5
View File
@@ -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")
+2 -2
View File
@@ -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
+4 -3
View File
@@ -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
+6 -6
View File
@@ -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")
+1 -1
View File
@@ -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
+2 -1
View File
@@ -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])")
+10 -11
View File
@@ -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:
+15 -15
View File
@@ -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 <PACKAGE NAME>")
print("")
print()
print("Test a specific kernel config again:")
print(" pmbootstrap kconfig check <PACKAGE NAME>")
print("")
print()
print("Run this check again (on all kernels you modified):")
print(" pmbootstrap ci kconfig")
print("")
print()
print("---")
print("")
print()
if __name__ == "__main__":
+5 -3
View File
@@ -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):
+1 -1
View File
@@ -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
+4 -6
View File
@@ -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
+1 -1
View File
@@ -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():