Replace some Any instances with specific type hints (#2973)
This commit is contained in:
parent
0a1d036750
commit
6a6642a9c1
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from ..lib.storage import storage
|
from ..lib.storage import storage
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ class Profile:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.description = description
|
self.description = description
|
||||||
self.profile_type = profile_type
|
self.profile_type = profile_type
|
||||||
self.custom_settings: dict[str, Any] = {}
|
self.custom_settings: dict[str, str | None] = {}
|
||||||
self.advanced = advanced
|
self.advanced = advanced
|
||||||
|
|
||||||
self._support_gfx_driver = support_gfx_driver
|
self._support_gfx_driver = support_gfx_driver
|
||||||
|
|
@ -124,7 +124,7 @@ class Profile:
|
||||||
are needed
|
are needed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def json(self) -> dict[str, Any]:
|
def json(self) -> dict[str, str]:
|
||||||
"""
|
"""
|
||||||
Returns a json representation of the profile
|
Returns a json representation of the profile
|
||||||
"""
|
"""
|
||||||
|
|
@ -136,7 +136,7 @@ class Profile:
|
||||||
"""
|
"""
|
||||||
return SelectResult.NewSelection
|
return SelectResult.NewSelection
|
||||||
|
|
||||||
def set_custom_settings(self, settings: dict[str, Any]) -> None:
|
def set_custom_settings(self, settings: dict[str, str | None]) -> None:
|
||||||
"""
|
"""
|
||||||
Set the custom settings for the profile.
|
Set the custom settings for the profile.
|
||||||
This is also called when the settings are parsed from the config
|
This is also called when the settings are parsed from the config
|
||||||
|
|
@ -185,7 +185,7 @@ class Profile:
|
||||||
def is_greeter_supported(self) -> bool:
|
def is_greeter_supported(self) -> bool:
|
||||||
return self._support_greeter
|
return self._support_greeter
|
||||||
|
|
||||||
def preview_text(self) -> str | None:
|
def preview_text(self) -> str:
|
||||||
"""
|
"""
|
||||||
Override this method to provide a preview text for the profile
|
Override this method to provide a preview text for the profile
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class XorgProfile(Profile):
|
||||||
)
|
)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def preview_text(self) -> str | None:
|
def preview_text(self) -> str:
|
||||||
text = str(_('Environment type: {}')).format(self.profile_type.value)
|
text = str(_('Environment type: {}')).format(self.profile_type.value)
|
||||||
if packages := self.packages_text():
|
if packages := self.packages_text():
|
||||||
text += f'\n{packages}'
|
text += f'\n{packages}'
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import uuid
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any, NotRequired, TypedDict
|
from typing import TYPE_CHECKING, NotRequired, TypedDict
|
||||||
|
|
||||||
import parted
|
import parted
|
||||||
from parted import Disk, Geometry, Partition
|
from parted import Disk, Geometry, Partition
|
||||||
|
|
@ -422,7 +422,7 @@ class _PartitionInfo:
|
||||||
sector_size = self.partition.geometry.device.sectorSize
|
sector_size = self.partition.geometry.device.sectorSize
|
||||||
return SectorSize(sector_size, Unit.B)
|
return SectorSize(sector_size, Unit.B)
|
||||||
|
|
||||||
def table_data(self) -> dict[str, Any]:
|
def table_data(self) -> dict[str, str]:
|
||||||
end = self.start + self.length
|
end = self.start + self.length
|
||||||
|
|
||||||
part_info = {
|
part_info = {
|
||||||
|
|
@ -496,7 +496,7 @@ class _DeviceInfo:
|
||||||
read_only: bool
|
read_only: bool
|
||||||
dirty: bool
|
dirty: bool
|
||||||
|
|
||||||
def table_data(self) -> dict[str, Any]:
|
def table_data(self) -> dict[str, str | int | bool]:
|
||||||
total_free_space = sum([region.get_length(unit=Unit.MiB) for region in self.free_space_regions])
|
total_free_space = sum([region.get_length(unit=Unit.MiB) for region in self.free_space_regions])
|
||||||
return {
|
return {
|
||||||
'Model': self.model,
|
'Model': self.model,
|
||||||
|
|
@ -601,7 +601,7 @@ class DeviceGeometry:
|
||||||
def get_length(self, unit: Unit = Unit.sectors) -> int:
|
def get_length(self, unit: Unit = Unit.sectors) -> int:
|
||||||
return self._geometry.getLength(unit.name)
|
return self._geometry.getLength(unit.name)
|
||||||
|
|
||||||
def table_data(self) -> dict[str, Any]:
|
def table_data(self) -> dict[str, str | int]:
|
||||||
start = Size(self._geometry.start, Unit.sectors, self._sector_size)
|
start = Size(self._geometry.start, Unit.sectors, self._sector_size)
|
||||||
end = Size(self._geometry.end, Unit.sectors, self._sector_size)
|
end = Size(self._geometry.end, Unit.sectors, self._sector_size)
|
||||||
length = Size(self._geometry.getLength(), Unit.sectors, self._sector_size)
|
length = Size(self._geometry.getLength(), Unit.sectors, self._sector_size)
|
||||||
|
|
@ -946,7 +946,7 @@ class PartitionModification:
|
||||||
'btrfs': [vol.json() for vol in self.btrfs_subvols]
|
'btrfs': [vol.json() for vol in self.btrfs_subvols]
|
||||||
}
|
}
|
||||||
|
|
||||||
def table_data(self) -> dict[str, Any]:
|
def table_data(self) -> dict[str, str]:
|
||||||
"""
|
"""
|
||||||
Called for displaying data in table format
|
Called for displaying data in table format
|
||||||
"""
|
"""
|
||||||
|
|
@ -958,7 +958,7 @@ class PartitionModification:
|
||||||
'End': self.end.format_size(Unit.sectors, self.start.sector_size, include_unit=False),
|
'End': self.end.format_size(Unit.sectors, self.start.sector_size, include_unit=False),
|
||||||
'Size': self.length.format_highest(),
|
'Size': self.length.format_highest(),
|
||||||
'FS type': self.fs_type.value if self.fs_type else 'Unknown',
|
'FS type': self.fs_type.value if self.fs_type else 'Unknown',
|
||||||
'Mountpoint': self.mountpoint if self.mountpoint else '',
|
'Mountpoint': str(self.mountpoint) if self.mountpoint else '',
|
||||||
'Mount options': ', '.join(self.mount_options),
|
'Mount options': ', '.join(self.mount_options),
|
||||||
'Flags': ', '.join([f.description for f in self.flags]),
|
'Flags': ', '.join([f.description for f in self.flags]),
|
||||||
}
|
}
|
||||||
|
|
@ -1132,7 +1132,7 @@ class LvmVolume:
|
||||||
'btrfs': [vol.json() for vol in self.btrfs_subvols]
|
'btrfs': [vol.json() for vol in self.btrfs_subvols]
|
||||||
}
|
}
|
||||||
|
|
||||||
def table_data(self) -> dict[str, Any]:
|
def table_data(self) -> dict[str, str]:
|
||||||
part_mod = {
|
part_mod = {
|
||||||
'Type': self.status.value,
|
'Type': self.status.value,
|
||||||
'Name': self.name,
|
'Name': self.name,
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class LocaleMenu(AbstractSubMenu):
|
||||||
locale_conf: LocaleConfiguration
|
locale_conf: LocaleConfiguration
|
||||||
):
|
):
|
||||||
self._locale_conf = locale_conf
|
self._locale_conf = locale_conf
|
||||||
self._data_store: dict[str, Any] = {}
|
self._data_store: dict[str, str] = {}
|
||||||
menu_optioons = self._define_menu_options()
|
menu_optioons = self._define_menu_options()
|
||||||
|
|
||||||
self._item_group = MenuItemGroup(menu_optioons, sort_items=False, checkmarks=True)
|
self._item_group = MenuItemGroup(menu_optioons, sort_items=False, checkmarks=True)
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ class AbstractViewport:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def add_str(self, screen: Any, row: int, col: int, text: str, color: STYLE) -> None:
|
def add_str(self, screen: 'curses._CursesWindow', row: int, col: int, text: str, color: STYLE) -> None:
|
||||||
try:
|
try:
|
||||||
screen.addstr(row, col, text, Tui.t().get_color(color))
|
screen.addstr(row, col, text, Tui.t().get_color(color))
|
||||||
except curses.error:
|
except curses.error:
|
||||||
|
|
@ -1383,7 +1383,7 @@ class Tui:
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def screen(self) -> Any:
|
def screen(self) -> 'curses._CursesWindow':
|
||||||
return self._screen
|
return self._screen
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,6 @@ warn_unused_ignores = true
|
||||||
module = "archinstall.default_profiles.*"
|
module = "archinstall.default_profiles.*"
|
||||||
disallow_any_explicit = true
|
disallow_any_explicit = true
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
|
||||||
module = "archinstall.default_profiles.profile"
|
|
||||||
disallow_any_explicit = false
|
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
module = "archinstall.examples.*"
|
module = "archinstall.examples.*"
|
||||||
disallow_any_explicit = true
|
disallow_any_explicit = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue