Enable truthy-bool checks in mypy and fix related warnings (#3528)

This commit is contained in:
correctmost 2025-05-29 02:11:32 +00:00 committed by GitHub
parent b2b36a2cef
commit 3da78fcb49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 25 additions and 31 deletions

View File

@ -323,17 +323,17 @@ class PartitioningList(ListManager[DiskSegment]):
partition.invert_flag(PartitionFlag.XBOOTLDR)
case 'set_filesystem':
fs_type = self._prompt_partition_fs_type()
if fs_type:
if partition.is_swap():
partition.invert_flag(PartitionFlag.SWAP)
partition.fs_type = fs_type
if partition.is_swap():
partition.mountpoint = None
partition.flags = []
partition.set_flag(PartitionFlag.SWAP)
# btrfs subvolumes will define mountpoints
if fs_type == FilesystemType.Btrfs:
partition.mountpoint = None
if partition.is_swap():
partition.invert_flag(PartitionFlag.SWAP)
partition.fs_type = fs_type
if partition.is_swap():
partition.mountpoint = None
partition.flags = []
partition.set_flag(PartitionFlag.SWAP)
# btrfs subvolumes will define mountpoints
if fs_type == FilesystemType.Btrfs:
partition.mountpoint = None
case 'btrfs_mark_compressed':
self._toggle_mount_option(partition, BtrfsMountOption.compress)
case 'btrfs_mark_nodatacow':

View File

@ -511,18 +511,17 @@ class GlobalMenu(AbstractMenu[None]):
users = ask_for_additional_users(defined_users=preset)
return users
def _mirror_configuration(self, preset: MirrorConfiguration | None = None) -> MirrorConfiguration | None:
def _mirror_configuration(self, preset: MirrorConfiguration | None = None) -> MirrorConfiguration:
mirror_configuration = MirrorMenu(preset=preset).run()
if mirror_configuration:
if mirror_configuration.optional_repositories:
# reset the package list cache in case the repository selection has changed
list_available_packages.cache_clear()
if mirror_configuration.optional_repositories:
# reset the package list cache in case the repository selection has changed
list_available_packages.cache_clear()
# enable the repositories in the config
pacman_config = PacmanConfig(None)
pacman_config.enable(mirror_configuration.optional_repositories)
pacman_config.apply()
# enable the repositories in the config
pacman_config = PacmanConfig(None)
pacman_config.enable(mirror_configuration.optional_repositories)
pacman_config.apply()
return mirror_configuration

View File

@ -1012,7 +1012,7 @@ class Installer:
# TODO: We need to detect if the encrypted device is a whole disk encryption,
# or simply a partition encryption. Right now we assume it's a partition (and we always have)
if self._disk_encryption and self._disk_encryption.hsm_device:
if self._disk_encryption.hsm_device:
debug(f'Root partition is an encrypted device, identifying by UUID: {root_partition.uuid}')
# Note: UUID must be used, not PARTUUID for sd-encrypt to work
kernel_parameters.append(f'rd.luks.name={root_partition.uuid}=root')
@ -1672,8 +1672,7 @@ class Installer:
if result := plugin.on_user_created(self, user):
handled_by_plugin = result
if user.password:
self.set_user_password(user)
self.set_user_password(user)
for group in user.groups:
SysCommand(f'arch-chroot {self.target} gpasswd -a {user.username} {group}')
@ -1684,7 +1683,7 @@ class Installer:
def set_user_password(self, user: User) -> bool:
info(f'Setting password for {user.username}')
enc_password = user.password.enc_password if user.password else None
enc_password = user.password.enc_password
if not enc_password:
debug('User password is empty')

View File

@ -8,6 +8,7 @@ from ..models.packages import Repository
class PacmanConfig:
def __init__(self, target: Path | None):
self._config_path = Path('/etc') / 'pacman.conf'
self._config_remote_path: Path | None = None
if target:
self._config_remote_path = target / 'etc' / 'pacman.conf'

View File

@ -45,8 +45,7 @@ def perform_installation(mountpoint: Path) -> None:
) as installation:
# Mount all the drives to the desired mountpoint
# This *can* be done outside of the installation, but the installer can deal with it.
if disk_config:
installation.mount_ordered_layout()
installation.mount_ordered_layout()
# to generate a fstab directory holder. Avoids an error on exit and at the same time checks the procedure
target = Path(f'{mountpoint}/etc/fstab')

View File

@ -13,7 +13,6 @@ from typing import Literal, override
from archinstall.lib.translationhandler import tr
from ..lib.output import debug
from .help import Help
from .menu_item import MenuItem, MenuItemGroup, MenuItemsState
from .result import Result, ResultType
@ -87,10 +86,6 @@ class AbstractCurses[ValueT](metaclass=ABCMeta):
return ViewportEntry(tr('Press Ctrl+h for help'), 0, 0, STYLE.NORMAL)
def _show_help(self) -> None:
if not self._help_window:
debug('no help window set')
return
help_text = Help.get_help_text()
lines = help_text.split('\n')

View File

@ -78,6 +78,7 @@ enable_error_code = [
"possibly-undefined",
"redundant-expr",
"redundant-self",
"truthy-bool",
"truthy-iterable",
"unimported-reveal",
"unused-awaitable",