diff --git a/archinstall/lib/args.py b/archinstall/lib/args.py index 286429a05b..b9a763ec90 100644 --- a/archinstall/lib/args.py +++ b/archinstall/lib/args.py @@ -132,7 +132,7 @@ def safe_json(self) -> dict[str, Any]: @classmethod def from_config(cls, args_config: dict[str, Any], args: Arguments) -> 'ArchConfig': - arch_config = ArchConfig() + arch_config = cls() arch_config.locale_config = LocaleConfiguration.parse_arg(args_config) diff --git a/archinstall/lib/models/bootloader.py b/archinstall/lib/models/bootloader.py index 22fa2c3106..b744754e1d 100644 --- a/archinstall/lib/models/bootloader.py +++ b/archinstall/lib/models/bootloader.py @@ -37,25 +37,25 @@ def get_default(cls) -> Bootloader: from ..args import arch_config_handler if arch_config_handler.args.skip_boot: - return Bootloader.NO_BOOTLOADER + return cls.NO_BOOTLOADER elif SysInfo.has_uefi(): - return Bootloader.Systemd + return cls.Systemd else: - return Bootloader.Grub + return cls.Grub @classmethod def from_arg(cls, bootloader: str, skip_boot: bool) -> Bootloader: # to support old configuration files bootloader = bootloader.capitalize() - bootloader_options = [e.value for e in Bootloader if e != Bootloader.NO_BOOTLOADER or skip_boot is True] + bootloader_options = [e.value for e in cls if e != cls.NO_BOOTLOADER or skip_boot is True] if bootloader not in bootloader_options: values = ', '.join(bootloader_options) warn(f'Invalid bootloader value "{bootloader}". Allowed values: {values}') sys.exit(1) - return Bootloader(bootloader) + return cls(bootloader) @dataclass diff --git a/archinstall/lib/models/device.py b/archinstall/lib/models/device.py index 85d780f99a..09a0945d8d 100644 --- a/archinstall/lib/models/device.py +++ b/archinstall/lib/models/device.py @@ -95,7 +95,7 @@ def parse_arg( if not config_type: raise ValueError('Missing disk layout configuration: config_type') - config = DiskLayoutConfiguration( + config = cls( config_type=DiskLayoutType(config_type), device_modifications=device_modifications, ) @@ -294,7 +294,7 @@ def json(self) -> _SectorSizeSerialization: @classmethod def parse_args(cls, arg: _SectorSizeSerialization) -> SectorSize: - return SectorSize( + return cls( arg['value'], Unit[arg['unit']], ) @@ -333,7 +333,7 @@ def json(self) -> _SizeSerialization: def parse_args(cls, size_arg: _SizeSerialization) -> Size: sector_size = size_arg['sector_size'] - return Size( + return cls( size_arg['value'], Unit[size_arg['unit']], SectorSize.parse_args(sector_size), @@ -553,7 +553,7 @@ def from_partition( SectorSize(partition.disk.device.sectorSize, Unit.B), ) - return _PartitionInfo( + return cls( partition=partition, name=partition.get_name(), type=partition_type, @@ -608,7 +608,7 @@ def from_disk(cls, disk: Disk) -> _DeviceInfo: sector_size = SectorSize(device.sectorSize, Unit.B) free_space = [DeviceGeometry(g, sector_size) for g in disk.getFreeSpaceRegions()] - return _DeviceInfo( + return cls( model=device.model.strip(), path=Path(device.path), type=device_type, @@ -632,7 +632,7 @@ class SubvolumeModification: @classmethod def from_existing_subvol_info(cls, info: _BtrfsSubvolumeInfo) -> SubvolumeModification: - return SubvolumeModification(info.name, mountpoint=info.mountpoint) + return cls(info.name, mountpoint=info.mountpoint) @classmethod def parse_args(cls, subvol_args: list[_SubvolumeModificationSerialization]) -> list[SubvolumeModification]: @@ -644,7 +644,7 @@ def parse_args(cls, subvol_args: list[_SubvolumeModificationSerialization]) -> l mountpoint = Path(entry['mountpoint']) if entry['mountpoint'] else None - mods.append(SubvolumeModification(entry['name'], mountpoint)) + mods.append(cls(entry['name'], mountpoint)) return mods @@ -723,10 +723,10 @@ class PartitionType(Enum): @classmethod def get_type_from_code(cls, code: int) -> PartitionType: if code == parted.PARTITION_NORMAL: - return PartitionType.Primary + return cls.Primary else: debug(f'Partition code not supported: {code}') - return PartitionType._Unknown + return cls._Unknown def get_partition_code(self) -> int | None: if self == PartitionType.Primary: @@ -923,7 +923,7 @@ def from_existing_partition(cls, partition_info: _PartitionInfo) -> PartitionMod mountpoint = partition_info.mountpoints[0] if partition_info.mountpoints else None subvol_mods = [] - return PartitionModification( + return cls( status=ModificationStatus.Exist, type=partition_info.type, start=partition_info.start, @@ -1433,10 +1433,10 @@ class EncryptionType(Enum): @classmethod def _encryption_type_mapper(cls) -> dict[str, 'EncryptionType']: return { - tr('No Encryption'): EncryptionType.NoEncryption, - tr('LUKS'): EncryptionType.Luks, - tr('LVM on LUKS'): EncryptionType.LvmOnLuks, - tr('LUKS on LVM'): EncryptionType.LuksOnLvm, + tr('No Encryption'): cls.NoEncryption, + tr('LUKS'): cls.Luks, + tr('LVM on LUKS'): cls.LvmOnLuks, + tr('LUKS on LVM'): cls.LuksOnLvm, } @classmethod @@ -1539,7 +1539,7 @@ def parse_arg( if vol.obj_id in disk_encryption.get('lvm_volumes', []): volumes.append(vol) - enc = DiskEncryption( + enc = cls( EncryptionType(disk_encryption['encryption_type']), password, enc_partitions, @@ -1583,7 +1583,7 @@ def table_data(self) -> dict[str, str]: @classmethod def parse_arg(cls, arg: _Fido2DeviceSerialization) -> 'Fido2Device': - return Fido2Device( + return cls( Path(arg['path']), arg['manufacturer'], arg['product'], diff --git a/archinstall/lib/models/mirrors.py b/archinstall/lib/models/mirrors.py index a013eb0a71..b4d35ae2af 100644 --- a/archinstall/lib/models/mirrors.py +++ b/archinstall/lib/models/mirrors.py @@ -195,7 +195,7 @@ def parse_args(cls, args: list[dict[str, str]]) -> list['CustomRepository']: configs = [] for arg in args: configs.append( - CustomRepository( + cls( arg['name'], arg['url'], SignCheck(arg['sign_check']), @@ -221,7 +221,7 @@ def parse_args(cls, args: list[dict[str, str]]) -> list['CustomServer']: configs = [] for arg in args: configs.append( - CustomServer(arg['url']), + cls(arg['url']), ) return configs @@ -305,7 +305,7 @@ def parse_args( args: dict[str, Any], backwards_compatible_repo: list[Repository] = [], ) -> 'MirrorConfiguration': - config = MirrorConfiguration() + config = cls() mirror_regions = args.get('mirror_regions', []) if mirror_regions: diff --git a/archinstall/lib/models/network.py b/archinstall/lib/models/network.py index e674e60914..b332e2c1fd 100644 --- a/archinstall/lib/models/network.py +++ b/archinstall/lib/models/network.py @@ -254,7 +254,7 @@ def from_wpa_cli_output(cls, list_networks: str) -> list[WifiConfiguredNetwork]: flags: list[str] = [] networks.append( - WifiConfiguredNetwork( + cls( network_id=int(parts[0]), ssid=parts[1], bssid=parts[2], diff --git a/archinstall/lib/models/packages.py b/archinstall/lib/models/packages.py index 218981c0f0..bbafaa216c 100644 --- a/archinstall/lib/models/packages.py +++ b/archinstall/lib/models/packages.py @@ -166,7 +166,7 @@ def from_available_packages( if len(group) == 0: continue - pkg_groups.setdefault(group, PackageGroup(group)) + pkg_groups.setdefault(group, cls(group)) pkg_groups[group].packages.append(pkg.name) return pkg_groups diff --git a/archinstall/lib/models/profile.py b/archinstall/lib/models/profile.py index 80cbde7a19..31ee1759a8 100644 --- a/archinstall/lib/models/profile.py +++ b/archinstall/lib/models/profile.py @@ -40,7 +40,7 @@ def parse_arg(cls, arg: _ProfileConfigurationSerialization) -> 'ProfileConfigura greeter = arg.get('greeter', None) gfx_driver = arg.get('gfx_driver', None) - return ProfileConfiguration( + return cls( profile, GfxDriver(gfx_driver) if gfx_driver else None, GreeterType(greeter) if greeter else None, diff --git a/archinstall/lib/models/users.py b/archinstall/lib/models/users.py index 8ff1a31a6e..ed65972dc4 100644 --- a/archinstall/lib/models/users.py +++ b/archinstall/lib/models/users.py @@ -59,45 +59,45 @@ def _check_password_strength( if digit and upper and lower and symbol: match length: case num if 13 <= num: - return PasswordStrength.STRONG + return cls.STRONG case num if 11 <= num <= 12: - return PasswordStrength.MODERATE + return cls.MODERATE case num if 7 <= num <= 10: - return PasswordStrength.WEAK + return cls.WEAK case num if num <= 6: - return PasswordStrength.VERY_WEAK + return cls.VERY_WEAK elif digit and upper and lower: match length: case num if 14 <= num: - return PasswordStrength.STRONG + return cls.STRONG case num if 11 <= num <= 13: - return PasswordStrength.MODERATE + return cls.MODERATE case num if 7 <= num <= 10: - return PasswordStrength.WEAK + return cls.WEAK case num if num <= 6: - return PasswordStrength.VERY_WEAK + return cls.VERY_WEAK elif upper and lower: match length: case num if 15 <= num: - return PasswordStrength.STRONG + return cls.STRONG case num if 12 <= num <= 14: - return PasswordStrength.MODERATE + return cls.MODERATE case num if 7 <= num <= 11: - return PasswordStrength.WEAK + return cls.WEAK case num if num <= 6: - return PasswordStrength.VERY_WEAK + return cls.VERY_WEAK elif lower or upper: match length: case num if 18 <= num: - return PasswordStrength.STRONG + return cls.STRONG case num if 14 <= num <= 17: - return PasswordStrength.MODERATE + return cls.MODERATE case num if 9 <= num <= 13: - return PasswordStrength.WEAK + return cls.WEAK case num if num <= 8: - return PasswordStrength.VERY_WEAK + return cls.VERY_WEAK - return PasswordStrength.VERY_WEAK + return cls.VERY_WEAK UserSerialization = TypedDict( @@ -204,7 +204,7 @@ def parse_arguments( if not username or password is None: continue - user = User( + user = cls( username=username, password=password, sudo=entry.get('sudo', False) is True, diff --git a/archinstall/tui/types.py b/archinstall/tui/types.py index 10697e7912..363627a3ea 100644 --- a/archinstall/tui/types.py +++ b/archinstall/tui/types.py @@ -76,7 +76,7 @@ class FrameProperties: @classmethod def max(cls, header: str) -> 'FrameProperties': - return FrameProperties( + return cls( header, FrameStyle.MAX, FrameStyle.MAX, @@ -84,7 +84,7 @@ def max(cls, header: str) -> 'FrameProperties': @classmethod def min(cls, header: str) -> 'FrameProperties': - return FrameProperties( + return cls( header, FrameStyle.MIN, FrameStyle.MIN,