Skip to content

Commit c2ea6ff

Browse files
authored
Add type annotations to global storage dictionary (#3548)
This will help catch issues like #3530.
1 parent b689656 commit c2ea6ff

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

archinstall/lib/installer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ def __init__(
9292

9393
self.post_base_install: list[Callable] = [] # type: ignore[type-arg]
9494

95-
# TODO: Figure out which one of these two we'll use.. But currently we're mixing them..
96-
storage['session'] = self
9795
storage['installation_session'] = self
9896

9997
self._modules: list[str] = []

archinstall/lib/storage.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@
66
#
77
# And Keeping this in dict ensures that variables are shared across imports.
88
from pathlib import Path
9-
from typing import Any
9+
from typing import TYPE_CHECKING, NotRequired, TypedDict
1010

11-
storage: dict[str, Any] = {
12-
'LOG_PATH': Path('/var/log/archinstall'),
11+
if TYPE_CHECKING:
12+
from archinstall.lib.boot import Boot
13+
from archinstall.lib.installer import Installer
14+
15+
16+
class _StorageDict(TypedDict):
17+
LOG_FILE: Path
18+
LOG_PATH: Path
19+
active_boot: NotRequired['Boot | None']
20+
installation_session: NotRequired['Installer']
21+
22+
23+
storage: _StorageDict = {
1324
'LOG_FILE': Path('install.log'),
25+
'LOG_PATH': Path('/var/log/archinstall'),
1426
}

0 commit comments

Comments
 (0)