Skip to content

Commit

Permalink
style(pikaur-static; makefile): add it to linting
Browse files Browse the repository at this point in the history
  • Loading branch information
actionless committed Sep 13, 2024
1 parent 048c70b commit 9313a77
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 14 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ RUFF := ruff
script_dir := $(shell readlink -e .)
APP_DIR := $(shell readlink -e "$(script_dir)")
TARGET_MODULE := pikaur
TARGETS := $(APP_DIR)/$(TARGET_MODULE)/ $(APP_DIR)/pikaur_test/ $(APP_DIR)/pikaur_meta_helpers/ $(APP_DIR)/packaging/usr/bin/pikaur $(shell ls $(APP_DIR)/maintenance_scripts/*.py)
TARGETS := \
$(APP_DIR)/$(TARGET_MODULE)/ \
$(APP_DIR)/pikaur_test/ \
$(APP_DIR)/pikaur_meta_helpers/ \
$(APP_DIR)/packaging/usr/bin/pikaur \
$(shell ls $(APP_DIR)/maintenance_scripts/*.py) \
$(shell ls $(APP_DIR)/pikaur_static/*.py)
GLOBALS_IGNORES := \
-e ': Final' \
-e ' \# nonfinal-ignore' \
Expand Down
43 changes: 43 additions & 0 deletions maintenance_scripts/vulture_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# pylint: disable=import-error,no-name-in-module
from vulture.whitelist_utils import Whitelist # type: ignore[import-untyped]

###############################################################################
#
# vulture --make-whitelist pikaur_static/*.py
#
###############################################################################

whitelist: Whitelist = Whitelist() # type: ignore[no-any-unimported]

whitelist.__new__
Expand Down Expand Up @@ -58,6 +64,43 @@
whitelist.news.MLStripper.handle_starttag
whitelist.news.MLStripper.strict

whitelist.pikaur_static.pacman_fallback._.compute_requiredby
whitelist.pikaur_static.pacman_fallback._.compute_optionalfor
whitelist.pikaur_static.pacman_fallback.PacmanPackageInfoType
whitelist.pikaur_static.pacman_fallback.PackageDBCommonType
whitelist.pikaur_static.pyalpm._.register_syncdb
whitelist.pikaur_static.pyalpm._.get_syncdbs
whitelist.pikaur_static.pyalpm._.get_localdb
whitelist.pikaur_static.pyalpm.LOG_WARNING
whitelist.pikaur_static.pyalpm.LOG_ERROR
whitelist.pikaur_static.pyalpm.vercmp
whitelist.pikaur_static.pypyalpm._.get_pkg
whitelist.pikaur_static.pypyalpm._.compute_requiredby
whitelist.pikaur_static.pypyalpm._.compute_optionalfor
whitelist.pikaur_static.pypyalpm._.search
whitelist.pikaur_static.pypyalpm._.all
whitelist.pikaur_static.pypyalpm.has_scriptlet
whitelist.pikaur_static.pypyalpm.base64_sig
whitelist.pikaur_static.pypyalpm.NOT_FOUND_ATOM
whitelist.pikaur_static.pypyalpm.validation
whitelist.pikaur_static.pypyalpm.url
whitelist.pikaur_static.pypyalpm.size
whitelist.pikaur_static.pypyalpm.sha256sum
whitelist.pikaur_static.pypyalpm.replaces
whitelist.pikaur_static.pypyalpm.packager
whitelist.pikaur_static.pypyalpm.md5sum
whitelist.pikaur_static.pypyalpm.licenses
whitelist.pikaur_static.pypyalpm.isize
whitelist.pikaur_static.pypyalpm.installdate
whitelist.pikaur_static.pypyalpm.groups
whitelist.pikaur_static.pypyalpm.filename
whitelist.pikaur_static.pypyalpm.desc
whitelist.pikaur_static.pypyalpm.data
whitelist.pikaur_static.pypyalpm.conflicts
whitelist.pikaur_static.pypyalpm.builddate
whitelist.pikaur_static.pypyalpm.base
whitelist.pikaur_static.pypyalpm.arch

whitelist.pikaur_test.helpers.DefaultArg
whitelist.pikaur_test.setUpClass
whitelist.pikaur_test.tearDownClass
Expand Down
6 changes: 4 additions & 2 deletions pikaur_static/pikaur-static.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/python3 -u
# pylint: disable=invalid-name
"""Licensed under GPLv3, see https://www.gnu.org/licenses/"""

import os
PIKAUR_NAME_ENV_NAME = "PIKAUR_NAME"
import os # noqa: I001
from typing import Final
PIKAUR_NAME_ENV_NAME: Final = "PIKAUR_NAME"
os.environ[PIKAUR_NAME_ENV_NAME] = os.environ.get(PIKAUR_NAME_ENV_NAME, "pikaur-static")
from pikaur.main import main # pylint: disable=wrong-import-position # noqa: E402

Expand Down
7 changes: 4 additions & 3 deletions pikaur_static/pyalpm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: INP001
"""
PyALPM compatibility interface for PypyALPM.
To be used with apps depending on pyalpm with pypyalpm.
Expand All @@ -6,9 +7,9 @@

import pypyalpm

DB = pypyalpm.DB
Package = pypyalpm.Package
vercmp = pypyalpm.compare_versions
DB = pypyalpm.DB # nonfinal-ignore
Package = pypyalpm.Package # nonfinal-ignore
vercmp = pypyalpm.compare_versions # nonfinal-ignore


LOG_ERROR: Final = True
Expand Down
16 changes: 8 additions & 8 deletions pikaur_static/pypyalpm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=invalid-name,line-too-long
# pylint: disable=invalid-name,line-too-long # noqa: INP001
"""
Pure-python alpm implementation backported from Pikaur v0.6
with compatibility layer added for easier integration with pyalpm interface.
Expand All @@ -16,7 +16,7 @@
if TYPE_CHECKING:
from collections.abc import Iterable

VERBOSE: bool = False
VERBOSE: bool = False # nonfinal-ignore
for verbose_flag in (
"--verbose",
"--debug",
Expand All @@ -29,14 +29,14 @@
FORCE_PACMAN_CLI_DB: bool = "--force-pacman-cli-db" in sys.argv


NOT_FOUND_ATOM = object()
NOT_FOUND_ATOM: Final = object()

DB_NAME_LOCAL: Final = "local"

SUPPORTED_ALPM_VERSION: Final = "9"
# SUPPORTED_ALPM_VERSION: Final = "99999" # used for testing only

PACMAN_DB_PATH = "/var/lib/pacman"
PACMAN_DB_PATH: Final = "/var/lib/pacman"


def debug(*args: Any) -> None:
Expand Down Expand Up @@ -177,7 +177,7 @@ def __init__(self) -> None:
################################################################################


PACMAN_LIST_FIELDS = (
PACMAN_LIST_FIELDS: Final = (
"conflicts",
"replaces",
"depends",
Expand All @@ -193,17 +193,17 @@ def __init__(self) -> None:
)


PACMAN_INT_FIELDS = (
PACMAN_INT_FIELDS: Final = (
"reason",
)


PACMAN_DICT_FIELDS = (
PACMAN_DICT_FIELDS: Final = (
"optdepends",
)


DB_INFO_TRANSLATION = {
DB_INFO_TRANSLATION: Final = {
"%NAME%": "name",
"%VERSION%": "version",
"%PROVIDES%": "provides",
Expand Down

0 comments on commit 9313a77

Please sign in to comment.