]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
installer/rpm: make RpmRepository a dataclass
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 15 Jun 2024 19:57:49 +0000 (21:57 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Jun 2024 12:58:40 +0000 (14:58 +0200)
Dataclasses are the more modern approach, with better string representation and
less hacks. A NamedTuple is also a tuple, which is rather surprising when we
don't use that.

mkosi/installer/rpm.py

index d4ce79848d7446b16a050033c9fb81aa42baa28c..8dcdf96b856f4cb642a2b9e21731f1202ed89342 100644 (file)
@@ -1,16 +1,18 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
+import dataclasses
 import subprocess
 import textwrap
 from pathlib import Path
-from typing import NamedTuple, Optional
+from typing import Optional
 
 from mkosi.context import Context
 from mkosi.run import run
 from mkosi.types import PathString
 
 
-class RpmRepository(NamedTuple):
+@dataclasses.dataclass(frozen=True)
+class RpmRepository:
     id: str
     url: str
     gpgurls: tuple[str, ...]