Skip to content

Commit aa44474

Browse files
authored
Replace an Any instance with TypedDict (#3261)
1 parent ae19299 commit aa44474

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

archinstall/lib/models/users.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import dataclass
22
from enum import Enum
3-
from typing import TYPE_CHECKING, Any, override
3+
from typing import TYPE_CHECKING, TypedDict, override
44

55
if TYPE_CHECKING:
66
from collections.abc import Callable
@@ -103,6 +103,9 @@ def _check_password_strength(
103103
return PasswordStrength.VERY_WEAK
104104

105105

106+
_UserSerialization = TypedDict('_UserSerialization', {'username': str, '!password': str, 'sudo': bool})
107+
108+
106109
@dataclass
107110
class User:
108111
username: str
@@ -115,15 +118,15 @@ def groups(self) -> list[str]:
115118
# if it's every going to be used
116119
return []
117120

118-
def json(self) -> dict[str, str | bool]:
121+
def json(self) -> _UserSerialization:
119122
return {
120123
'username': self.username,
121124
'!password': self.password,
122125
'sudo': self.sudo
123126
}
124127

125128
@classmethod
126-
def _parse(cls, config_users: list[dict[str, Any]]) -> list['User']:
129+
def _parse(cls, config_users: list[_UserSerialization]) -> list['User']:
127130
users = []
128131

129132
for entry in config_users:
@@ -153,8 +156,8 @@ def _parse_backwards_compatible(cls, config_users: dict[str, dict[str, str]], su
153156
@classmethod
154157
def parse_arguments(
155158
cls,
156-
config_users: list[dict[str, str]] | dict[str, dict[str, str]],
157-
config_superusers: list[dict[str, str]] | dict[str, dict[str, str]]
159+
config_users: list[_UserSerialization] | dict[str, dict[str, str]],
160+
config_superusers: dict[str, dict[str, str]] | None
158161
) -> list['User']:
159162
users = []
160163

0 commit comments

Comments
 (0)