Skip to content

Commit 03d9be8

Browse files
committed
Use StrEnum for FilesystemType
1 parent 93ea681 commit 03d9be8

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

archinstall/lib/models/device.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import math
33
import uuid
44
from dataclasses import dataclass, field
5-
from enum import Enum
5+
from enum import Enum, StrEnum, auto
66
from pathlib import Path
77
from typing import NotRequired, Self, TypedDict, override
88
from uuid import UUID
@@ -131,9 +131,14 @@ def parse_arg(
131131
for partition in entry.get('partitions', []):
132132
flags = [flag for f in partition.get('flags', []) if (flag := PartitionFlag.from_string(f))]
133133

134+
if fs_type := partition.get('fs_type'):
135+
fs_type = FilesystemType(fs_type)
136+
else:
137+
fs_type = None
138+
134139
device_partition = PartitionModification(
135140
status=ModificationStatus(partition['status']),
136-
fs_type=FilesystemType(partition['fs_type']) if partition.get('fs_type') else None,
141+
fs_type=fs_type,
137142
start=Size.parse_args(partition['start']),
138143
length=Size.parse_args(partition['size']),
139144
mount_options=partition['mount_options'],
@@ -777,17 +782,17 @@ def bytes(self) -> builtins.bytes:
777782
return uuid.UUID(self.value).bytes
778783

779784

780-
class FilesystemType(Enum):
781-
BTRFS = 'btrfs'
782-
EXT2 = 'ext2'
783-
EXT3 = 'ext3'
784-
EXT4 = 'ext4'
785-
F2FS = 'f2fs'
786-
FAT12 = 'fat12'
787-
FAT16 = 'fat16'
788-
FAT32 = 'fat32'
789-
NTFS = 'ntfs'
790-
XFS = 'xfs'
785+
class FilesystemType(StrEnum):
786+
BTRFS = auto()
787+
EXT2 = auto()
788+
EXT3 = auto()
789+
EXT4 = auto()
790+
F2FS = auto()
791+
FAT12 = auto()
792+
FAT16 = auto()
793+
FAT32 = auto()
794+
NTFS = auto()
795+
XFS = auto()
791796
LINUX_SWAP = 'linux-swap'
792797

793798
# this is not a FS known to parted, so be careful

0 commit comments

Comments
 (0)