Skip to content

Commit

Permalink
chores,style(maintenance_scripts: lint): sync with pikaur - 2 and f…
Browse files Browse the repository at this point in the history
…ix some of the newly-found warnings
  • Loading branch information
actionless committed Jun 16, 2024
1 parent 0a74e78 commit b0829b6
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 25 deletions.
2 changes: 2 additions & 0 deletions maintenance_scripts/get_global_expressions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ result=$(
grep -REn "^[a-zA-Z_]+ = [^'\"].*" "$@" --color=always \
| grep -Ev \
-e ': Final' \
-e ' # nonfinal-ignore' \
-e ' # checkglobals-ignore' \
\
-e ' =.*\|' \
-e ' = [a-zA-Z_]+\[' \
Expand Down
25 changes: 15 additions & 10 deletions maintenance_scripts/makefile_shellcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
import subprocess # nosec B404
import sys
import tempfile
from typing import Final

MAKEFILE = "./Makefile"
MAKEFILE: str = "./Makefile"
if len(sys.argv) > 1:
MAKEFILE = sys.argv[1]

DEFAULT_ENCODING = "utf-8"
MAKE_SHELL = os.environ.get("MAKE_SHELL", "sh")
DEFAULT_ENCODING: Final = "utf-8"
MAKE_SHELL: Final = os.environ.get("MAKE_SHELL", "sh")
# SKIP_TARGETS_WITH_CHARS = ("%", )
SKIP_TARGETS_WITH_CHARS = ("%", "/")
SKIP_TARGETS = (".PHONY", ".PRECIOUS")
SKIP_TARGETS_WITH_CHARS: Final = ("%", "/")
SKIP_TARGETS: Final = (".PHONY", ".PRECIOUS")


_ALL: Final = "all"


def get_targets() -> list[str]:
Expand All @@ -28,10 +32,11 @@ def get_targets() -> list[str]:
],
encoding=DEFAULT_ENCODING,
).splitlines()
not_a_target_comment = "# Not a target:"

targets = []
for idx, line in enumerate(lines):
if lines[idx - 1] == "# Not a target:":
if lines[idx - 1] == not_a_target_comment:
continue

word = line.split(" ", maxsplit=1)[0]
Expand All @@ -53,8 +58,8 @@ def get_targets() -> list[str]:
targets = sorted(set(targets), reverse=True)

# check it last:
targets.remove("all")
targets.append("all")
targets.remove(_ALL)
targets.append(_ALL)
return targets


Expand All @@ -74,8 +79,8 @@ def print_error_in_target(target: str) -> None:
def main() -> None:
print("Starting the check...")
targets = get_targets()
if "all" not in targets:
print("ERROR: `all` target is not defined.")
if _ALL not in targets:
print(f"ERROR: `{_ALL}` target is not defined.")
sys.exit(1)

print("\nMake targets:")
Expand Down
2 changes: 1 addition & 1 deletion maintenance_scripts/vulture_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from vulture.whitelist_utils import Whitelist # pylint: disable=import-error,no-name-in-module

whitelist = Whitelist()
whitelist: Whitelist = Whitelist()

# typehints
whitelist.typing.Any
Expand Down
2 changes: 1 addition & 1 deletion oomox_gui/export_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ExportBoxT(Gtk.Box):
ExportBaseClassT = TypeVar("ExportBaseClassT", ExportDialogT, ExportBoxT)

# # ExportWrapperBase = GObject.Object
ExportWrapperBase = Generic
ExportWrapperBase = Generic # checkglobals-ignore


class ExportWrapper(Generic[ExportBaseClassT]):
Expand Down
2 changes: 1 addition & 1 deletion oomox_gui/multi_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .theme_file import ThemeT


BaseClass = WindowWithActions
BaseClass = WindowWithActions # checkglobals-ignore


DEFAULT_PADDING: "Final[int]" = 8
Expand Down
2 changes: 1 addition & 1 deletion plugins/base16
Submodule base16 updated 1 files
+4 −4 oomox_plugin.py
2 changes: 1 addition & 1 deletion plugins/export_oomoxify
2 changes: 1 addition & 1 deletion plugins/icons_archdroid/oomox_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


PLUGIN_DIR: "Final" = os.path.dirname(os.path.realpath(__file__))
ARCHDROID_THEME_DIR = os.path.join(PLUGIN_DIR, "archdroid-icon-theme/")
ARCHDROID_THEME_DIR: "Final" = os.path.join(PLUGIN_DIR, "archdroid-icon-theme/")


class ArchdroidIconsExportDialog(CommonIconThemeExportDialog):
Expand Down
17 changes: 9 additions & 8 deletions plugins/import_from_image/oomox_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@

if TYPE_CHECKING:
from collections.abc import Callable, Sequence
from typing import Annotated, Any
from types import ModuleType
from typing import Annotated, Any, Final

from oomox_gui.color import HexColor, IntColor
from oomox_gui.theme_file import ThemeT


PLUGIN_DIR = os.path.dirname(os.path.realpath(__file__))
PLUGIN_DIR: "Final" = os.path.dirname(os.path.realpath(__file__))


LOW_QUALITY = 100
MEDIUM_QUALITY = 200
HIGH_QUALITY = 400
# ULTRA_QUALITY = 1000
LOW_QUALITY: "Final" = 100
MEDIUM_QUALITY: "Final" = 200
HIGH_QUALITY: "Final" = 400
# ULTRA_QUALITY: "Final" = 1000

ACCURACY = 40
ACCURACY: "Final" = 40

image_analyzer = get_plugin_module("ima", os.path.join(PLUGIN_DIR, "ima.py"))
image_analyzer: "ModuleType" = get_plugin_module("ima", os.path.join(PLUGIN_DIR, "ima.py"))


def sort_by_saturation(c: "IntColor") -> int: # pylint: disable=invalid-name
Expand Down
3 changes: 2 additions & 1 deletion plugins/import_xresources/oomox_plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import subprocess
from typing import Final

from oomox_gui.config import DEFAULT_ENCODING
from oomox_gui.plugin_api import OomoxImportPlugin
from oomox_gui.theme_model import get_theme_model

PLUGIN_DIR = os.path.dirname(os.path.realpath(__file__))
PLUGIN_DIR: Final = os.path.dirname(os.path.realpath(__file__))


class XrdbCache:
Expand Down

0 comments on commit b0829b6

Please sign in to comment.