-
Notifications
You must be signed in to change notification settings - Fork 669
Enable truthy-bool checks in mypy and fix related warnings #3528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable truthy-bool checks in mypy and fix related warnings #3528
Conversation
| # 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 1011 already assumes self._disk_encryption is not None
| if result := plugin.on_user_created(self, user): | ||
| handled_by_plugin = result | ||
|
|
||
| if user.password: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user.password is a Password object
| ) 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an earlier check on line 34
| return ViewportEntry(tr('Press Ctrl+h for help'), 0, 0, STYLE.NORMAL) | ||
|
|
||
| def _show_help(self) -> None: | ||
| if not self._help_window: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._help_window is always initialized:
archinstall/archinstall/tui/curses_menu.py
Lines 34 to 36 in 3df568d
| class AbstractCurses[ValueT](metaclass=ABCMeta): | |
| def __init__(self) -> None: | |
| self._help_window = self._set_help_viewport() |
|
|
||
| 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MirrorMenu.run() always returns a MirrorConfiguration:
archinstall/archinstall/lib/mirrors.py
Lines 299 to 301 in 3df568d
| def run(self) -> MirrorConfiguration: | |
| super().run() | |
| return self._mirror_config |
| partition.invert_flag(PartitionFlag.ESP) | ||
| partition.invert_flag(PartitionFlag.XBOOTLDR) | ||
| case 'set_filesystem': | ||
| fs_type = self._prompt_partition_fs_type() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_prompt_partition_fs_type does not allow skipping or resetting:
archinstall/archinstall/lib/disk/partitioning_menu.py
Lines 415 to 432 in 3df568d
| def _prompt_partition_fs_type(self, prompt: str | None = None) -> FilesystemType: | |
| fs_types = filter(lambda fs: fs != FilesystemType.Crypto_luks, FilesystemType) | |
| items = [MenuItem(fs.value, value=fs) for fs in fs_types] | |
| group = MenuItemGroup(items, sort_items=False) | |
| result = SelectMenu[FilesystemType]( | |
| group, | |
| header=prompt, | |
| alignment=Alignment.CENTER, | |
| frame=FrameProperties.min(tr('Filesystem')), | |
| allow_skip=False, | |
| ).run() | |
| match result.type_: | |
| case ResultType.Selection: | |
| return result.get_value() | |
| case _: | |
| raise ValueError('Unhandled result type') |
PR Description:
Docs: https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-expression-is-not-implicitly-true-in-boolean-context-truthy-bool
Tests and Checks