Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/models
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-10-03 18:31:17 +1100
committerGitHub <noreply@github.com>2023-10-03 18:31:17 +1100
commitedbc13590366e93bb8a85eacf104d5613bc5793a (patch)
treed26ddd0700b669f747522ae62ba1d71df1ff27d6 /archinstall/lib/models
parent5c903df55fac449baae1e9cc23b04f6beeb55364 (diff)
Extend the mypy checks (#2120)
* Extend the mypy checks * Update * Update * Update --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall/lib/models')
-rw-r--r--archinstall/lib/models/gen.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/archinstall/lib/models/gen.py b/archinstall/lib/models/gen.py
index cc8d7605..fb7e5751 100644
--- a/archinstall/lib/models/gen.py
+++ b/archinstall/lib/models/gen.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass
-from typing import Optional, List
+from typing import Optional, List, Dict, Any
@dataclass
@@ -87,6 +87,10 @@ class PackageSearchResult:
makedepends: List[str]
checkdepends: List[str]
+ @staticmethod
+ def from_json(data: Dict[str, Any]) -> 'PackageSearchResult':
+ return PackageSearchResult(**data)
+
@property
def pkg_version(self) -> str:
return self.pkgver
@@ -107,8 +111,18 @@ class PackageSearch:
page: int
results: List[PackageSearchResult]
- def __post_init__(self):
- self.results = [PackageSearchResult(**x) for x in self.results]
+ @staticmethod
+ def from_json(data: Dict[str, Any]) -> 'PackageSearch':
+ results = [PackageSearchResult.from_json(r) for r in data['results']]
+
+ return PackageSearch(
+ version=data['version'],
+ limit=data['limit'],
+ valid=data['valid'],
+ num_pages=data['num_pages'],
+ page=data['page'],
+ results=results
+ )
@dataclass