From d83595e9da9874afaa1e0741855bb7dfaac4e8da Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Thu, 29 May 2025 19:49:38 -0400 Subject: [PATCH] Add type annotations to global storage dictionary This will help catch issues like #3530. --- archinstall/lib/installer.py | 2 -- archinstall/lib/storage.py | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index e0f6da2d4e..7d918511fd 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -92,8 +92,6 @@ def __init__( self.post_base_install: list[Callable] = [] # type: ignore[type-arg] - # TODO: Figure out which one of these two we'll use.. But currently we're mixing them.. - storage['session'] = self storage['installation_session'] = self self._modules: list[str] = [] diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py index d8474fe10d..7c89609a8d 100644 --- a/archinstall/lib/storage.py +++ b/archinstall/lib/storage.py @@ -6,9 +6,21 @@ # # And Keeping this in dict ensures that variables are shared across imports. from pathlib import Path -from typing import Any +from typing import TYPE_CHECKING, NotRequired, TypedDict -storage: dict[str, Any] = { - 'LOG_PATH': Path('/var/log/archinstall'), +if TYPE_CHECKING: + from archinstall.lib.boot import Boot + from archinstall.lib.installer import Installer + + +class _StorageDict(TypedDict): + LOG_FILE: Path + LOG_PATH: Path + active_boot: NotRequired['Boot | None'] + installation_session: NotRequired['Installer'] + + +storage: _StorageDict = { 'LOG_FILE': Path('install.log'), + 'LOG_PATH': Path('/var/log/archinstall'), }