From f9e6120910d8081b384d6bd3d8ca6b10185b5ec8 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Thu, 30 Apr 2026 14:12:35 +0200 Subject: [PATCH] feat(typing): More types, cleaner structure --- config.schema.json | 5 +++- config/dtype.py | 56 ---------------------------------------- config/dtype/__init__.py | 9 +++++++ config/dtype/cmds.py | 14 ++++++++++ config/dtype/git.py | 11 ++++++++ config/dtype/others.py | 22 ++++++++++++++++ config/dtype/pkgs.py | 35 +++++++++++++++++++++++++ managers/pacman_conf.py | 0 8 files changed, 95 insertions(+), 57 deletions(-) delete mode 100644 config/dtype.py create mode 100644 config/dtype/__init__.py create mode 100644 config/dtype/cmds.py create mode 100644 config/dtype/git.py create mode 100644 config/dtype/others.py create mode 100644 config/dtype/pkgs.py create mode 100644 managers/pacman_conf.py diff --git a/config.schema.json b/config.schema.json index 648d1c8..c9ddf64 100644 --- a/config.schema.json +++ b/config.schema.json @@ -64,7 +64,10 @@ } } } - } + }, + "required": [ + "name" + ] } }, "reflector": { diff --git a/config/dtype.py b/config/dtype.py deleted file mode 100644 index ad88f85..0000000 --- a/config/dtype.py +++ /dev/null @@ -1,56 +0,0 @@ -from typing import Optional, TypedDict - - -class ArchMgrConfig(TypedDict): - pkgs: ArchMgrPkgConfig - users: list[ArchMgrUserConfig] - - -class ArchMgrPkgConfig(TypedDict): - individual: list[str] - bundles: list[object] # TODO: Better typing - repos: object # TODO: Repo typing - - -class ArchMgrUserConfig(TypedDict): - username: str - groups: list[str] - home_dir: bool - - -class ArchMgrBootConfig(TypedDict): - bootloader: str - esp_dir: str - theme_folder: str - os_prober: bool - - -class ArchMgrThemeConfig(TypedDict): - gtk: str - qt: str - font: str - icon_theme: str - cursor_theme: str - - -class ArchMgrGitConfig(TypedDict): - creds: object # TODO: - repos: object # TODO - - -class ArchMgrGitRepoConfig(TypedDict): - clone_path: str - url: str - - -class ArchMgrCmdsConfig(TypedDict): - always: ArchMgrCommand - once: ArchMgrCommand - - -class ArchMgrCommand(TypedDict): - cmd: str - name: Optional[str] - capture_output: Optional[bool] - hook: Optional[str] - user: Optional[str] diff --git a/config/dtype/__init__.py b/config/dtype/__init__.py new file mode 100644 index 0000000..41cd83c --- /dev/null +++ b/config/dtype/__init__.py @@ -0,0 +1,9 @@ +from typing import TypedDict + +from config.dtype.others import ArchMgrUserConfig +from config.dtype.pkgs import ArchMgrPkgConfig + + +class ArchMgrConfig(TypedDict): + pkgs: ArchMgrPkgConfig + users: list[ArchMgrUserConfig] diff --git a/config/dtype/cmds.py b/config/dtype/cmds.py new file mode 100644 index 0000000..6ee6959 --- /dev/null +++ b/config/dtype/cmds.py @@ -0,0 +1,14 @@ +from typing import Optional, TypedDict + + +class ArchMgrCmdsConfig(TypedDict): + always: ArchMgrCommand + once: ArchMgrCommand + + +class ArchMgrCommand(TypedDict): + cmd: str + name: Optional[str] + capture_output: Optional[bool] + hook: Optional[str] + user: Optional[str] diff --git a/config/dtype/git.py b/config/dtype/git.py new file mode 100644 index 0000000..b159f8f --- /dev/null +++ b/config/dtype/git.py @@ -0,0 +1,11 @@ +from typing import TypedDict + + +class ArchMgrGitConfig(TypedDict): + creds: dict # TODO: + repos: dict # TODO + + +class ArchMgrGitRepoConfig(TypedDict): + clone_path: str + url: str diff --git a/config/dtype/others.py b/config/dtype/others.py new file mode 100644 index 0000000..6e675b6 --- /dev/null +++ b/config/dtype/others.py @@ -0,0 +1,22 @@ +from typing import TypedDict + + +class ArchMgrUserConfig(TypedDict): + username: str + groups: list[str] + home_dir: bool + + +class ArchMgrBootConfig(TypedDict): + bootloader: str + esp_dir: str + theme_folder: str + os_prober: bool + + +class ArchMgrThemeConfig(TypedDict): + gtk: str + qt: str + font: str + icon_theme: str + cursor_theme: str diff --git a/config/dtype/pkgs.py b/config/dtype/pkgs.py new file mode 100644 index 0000000..bd79227 --- /dev/null +++ b/config/dtype/pkgs.py @@ -0,0 +1,35 @@ +from typing import Optional, TypedDict + + +class ArchMgrPkgConfig(TypedDict): + individual: list[str] + bundles: list[ArchMgrBundleConfig] + repos: ArchMgrRepoSettings + + +class ArchMgrReposConfig(TypedDict): + enabled_repos: list[ArchMgrRepoSettings] + reflector: ArchMgrReflectorConfig + + +class ArchMgrReflectorConfig(TypedDict): + enabled: bool + interval: Optional[int] + countries: Optional[list[str]] + count: Optional[int] + + +class ArchMgrBundleConfig(TypedDict): + name: str + ignored_pkgs: Optional[list[str]] + + +class ArchMgrRepoSettings(TypedDict): + name: str + setup_cmds: Optional[list[str]] + mirrors: ArchMgrRepoMirrors + + +class ArchMgrRepoMirrors(TypedDict): + use_default: bool + extra_mirrors: Optional[list[str]] diff --git a/managers/pacman_conf.py b/managers/pacman_conf.py new file mode 100644 index 0000000..e69de29