Fix most of the mypy errors in archinstall/default_profiles/ (#2636)

This commit is contained in:
correctmost 2024-08-27 01:07:49 -04:00 committed by GitHub
parent 446aa44007
commit 7835784be5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 51 additions and 51 deletions

View File

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class PipewireProfile(Profile): class PipewireProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__('Pipewire', ProfileType.Application) super().__init__('Pipewire', ProfileType.Application)
@property @property
@ -26,7 +26,7 @@ class PipewireProfile(Profile):
'wireplumber' 'wireplumber'
] ]
def _enable_pipewire_for_all(self, install_session: 'Installer'): def _enable_pipewire_for_all(self, install_session: 'Installer') -> None:
users: Union[User, List[User]] = archinstall.arguments.get('!users', []) users: Union[User, List[User]] = archinstall.arguments.get('!users', [])
if not isinstance(users, list): if not isinstance(users, list):
users = [users] users = [users]
@ -34,7 +34,7 @@ class PipewireProfile(Profile):
for user in users: for user in users:
install_session.arch_chroot('systemctl enable --user pipewire-pulse.service', run_as=user.username) install_session.arch_chroot('systemctl enable --user pipewire-pulse.service', run_as=user.username)
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
super().install(install_session) super().install(install_session)
install_session.add_additional_packages(self.packages) install_session.add_additional_packages(self.packages)
self._enable_pipewire_for_all(install_session) self._enable_pipewire_for_all(install_session)

View File

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class DesktopProfile(Profile): class DesktopProfile(Profile):
def __init__(self, current_selection: List[Profile] = []): def __init__(self, current_selection: List[Profile] = []) -> None:
super().__init__( super().__init__(
'Desktop', 'Desktop',
ProfileType.Desktop, ProfileType.Desktop,
@ -48,7 +48,7 @@ class DesktopProfile(Profile):
return None return None
def _do_on_select_profiles(self): def _do_on_select_profiles(self) -> None:
for profile in self.current_selection: for profile in self.current_selection:
profile.do_on_select() profile.do_on_select()
@ -70,11 +70,11 @@ class DesktopProfile(Profile):
case menu.MenuSelectionType.Reset: case menu.MenuSelectionType.Reset:
return SelectResult.ResetCurrent return SelectResult.ResetCurrent
def post_install(self, install_session: 'Installer'): def post_install(self, install_session: 'Installer') -> None:
for profile in self.current_selection: for profile in self.current_selection:
profile.post_install(install_session) profile.post_install(install_session)
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
# Install common packages for all desktop environments # Install common packages for all desktop environments
install_session.add_additional_packages(self.packages) install_session.add_additional_packages(self.packages)

View File

@ -9,7 +9,7 @@ if TYPE_CHECKING:
class AwesomeProfile(XorgProfile): class AwesomeProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Awesome', ProfileType.WindowMgr, description='') super().__init__('Awesome', ProfileType.WindowMgr, description='')
@property @property
@ -28,7 +28,7 @@ class AwesomeProfile(XorgProfile):
'xsel', 'xsel',
] ]
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
super().install(install_session) super().install(install_session)
# TODO: Copy a full configuration to ~/.config/awesome/rc.lua instead. # TODO: Copy a full configuration to ~/.config/awesome/rc.lua instead.
@ -60,4 +60,4 @@ class AwesomeProfile(XorgProfile):
xinitrc_data += 'exec awesome\n' xinitrc_data += 'exec awesome\n'
with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'w') as xinitrc: with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'w') as xinitrc:
xinitrc.write(xinitrc_data) xinitrc.write(xinitrc_data)

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class BspwmProfile(XorgProfile): class BspwmProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Bspwm', ProfileType.WindowMgr, description='') super().__init__('Bspwm', ProfileType.WindowMgr, description='')
@property @property

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class BudgieProfile(XorgProfile): class BudgieProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Budgie', ProfileType.DesktopEnv, description='') super().__init__('Budgie', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class CinnamonProfile(XorgProfile): class CinnamonProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Cinnamon', ProfileType.DesktopEnv, description='') super().__init__('Cinnamon', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -7,7 +7,7 @@ if TYPE_CHECKING:
_: Any _: Any
class CosmicProfile(XorgProfile): class CosmicProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('cosmic-epoch', ProfileType.DesktopEnv, description='', advanced=True) super().__init__('cosmic-epoch', ProfileType.DesktopEnv, description='', advanced=True)
@property @property

View File

@ -9,7 +9,7 @@ if TYPE_CHECKING:
class CutefishProfile(XorgProfile): class CutefishProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Cutefish', ProfileType.DesktopEnv, description='') super().__init__('Cutefish', ProfileType.DesktopEnv, description='')
@property @property
@ -23,5 +23,5 @@ class CutefishProfile(XorgProfile):
def default_greeter_type(self) -> Optional[GreeterType]: def default_greeter_type(self) -> Optional[GreeterType]:
return GreeterType.Sddm return GreeterType.Sddm
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
super().install(install_session) super().install(install_session)

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class DeepinProfile(XorgProfile): class DeepinProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Deepin', ProfileType.DesktopEnv, description='') super().__init__('Deepin', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class EnlighenmentProfile(XorgProfile): class EnlighenmentProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Enlightenment', ProfileType.WindowMgr, description='') super().__init__('Enlightenment', ProfileType.WindowMgr, description='')
@property @property

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class GnomeProfile(XorgProfile): class GnomeProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Gnome', ProfileType.DesktopEnv, description='') super().__init__('Gnome', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -16,7 +16,7 @@ class SeatAccess(Enum):
class HyprlandProfile(XorgProfile): class HyprlandProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Hyprland', ProfileType.DesktopEnv, description='') super().__init__('Hyprland', ProfileType.DesktopEnv, description='')
self.custom_settings = {'seat_access': None} self.custom_settings = {'seat_access': None}
@ -47,7 +47,7 @@ class HyprlandProfile(XorgProfile):
return [pref] return [pref]
return [] return []
def _ask_seat_access(self): def _ask_seat_access(self) -> None:
# need to activate seat service and add to seat group # need to activate seat service and add to seat group
title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) title = str(_('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)'))
title += str(_('\n\nChoose an option to give Hyprland access to your hardware')) title += str(_('\n\nChoose an option to give Hyprland access to your hardware'))
@ -64,5 +64,5 @@ class HyprlandProfile(XorgProfile):
def do_on_select(self): def do_on_select(self):
self._ask_seat_access() self._ask_seat_access()
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
super().install(install_session) super().install(install_session)

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class I3wmProfile(XorgProfile): class I3wmProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('i3-wm', ProfileType.WindowMgr, description='') super().__init__('i3-wm', ProfileType.WindowMgr, description='')
@property @property

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class LxqtProfile(XorgProfile): class LxqtProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Lxqt', ProfileType.DesktopEnv, description='') super().__init__('Lxqt', ProfileType.DesktopEnv, description='')
# NOTE: SDDM is the only officially supported greeter for LXQt, so unlike other DEs, lightdm is not used here. # NOTE: SDDM is the only officially supported greeter for LXQt, so unlike other DEs, lightdm is not used here.

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class MateProfile(XorgProfile): class MateProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Mate', ProfileType.DesktopEnv, description='') super().__init__('Mate', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -7,7 +7,7 @@ if TYPE_CHECKING:
_: Any _: Any
class PlasmaProfile(XorgProfile): class PlasmaProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('KDE Plasma', ProfileType.DesktopEnv, description='') super().__init__('KDE Plasma', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class QtileProfile(XorgProfile): class QtileProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Qtile', ProfileType.WindowMgr, description='') super().__init__('Qtile', ProfileType.WindowMgr, description='')
@property @property

View File

@ -16,7 +16,7 @@ class SeatAccess(Enum):
class SwayProfile(XorgProfile): class SwayProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Sway', 'Sway',
ProfileType.WindowMgr, ProfileType.WindowMgr,
@ -56,7 +56,7 @@ class SwayProfile(XorgProfile):
return [pref] return [pref]
return [] return []
def _ask_seat_access(self): def _ask_seat_access(self) -> None:
# need to activate seat service and add to seat group # need to activate seat service and add to seat group
title = str(_('Sway needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')) title = str(_('Sway needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)'))
title += str(_('\n\nChoose an option to give Sway access to your hardware')) title += str(_('\n\nChoose an option to give Sway access to your hardware'))
@ -73,5 +73,5 @@ class SwayProfile(XorgProfile):
def do_on_select(self): def do_on_select(self):
self._ask_seat_access() self._ask_seat_access()
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
super().install(install_session) super().install(install_session)

View File

@ -8,7 +8,7 @@ if TYPE_CHECKING:
class Xfce4Profile(XorgProfile): class Xfce4Profile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('Xfce4', ProfileType.DesktopEnv, description='') super().__init__('Xfce4', ProfileType.DesktopEnv, description='')
@property @property

View File

@ -58,7 +58,7 @@ class Profile:
support_gfx_driver: bool = False, support_gfx_driver: bool = False,
support_greeter: bool = False, support_greeter: bool = False,
advanced: bool = False advanced: bool = False
): ) -> None:
self.name = name self.name = name
self.description = description self.description = description
self.profile_type = profile_type self.profile_type = profile_type
@ -100,19 +100,19 @@ class Profile:
""" """
return None return None
def _advanced_check(self): def _advanced_check(self) -> bool:
""" """
Used to control if the Profile() should be visible or not in different contexts. Used to control if the Profile() should be visible or not in different contexts.
Returns True if --advanced is given on a Profile(advanced=True) instance. Returns True if --advanced is given on a Profile(advanced=True) instance.
""" """
return self.advanced is False or storage['arguments'].get('advanced', False) is True return self.advanced is False or storage['arguments'].get('advanced', False) is True
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
""" """
Performs installation steps when this profile was selected Performs installation steps when this profile was selected
""" """
def post_install(self, install_session: 'Installer'): def post_install(self, install_session: 'Installer') -> None:
""" """
Hook that will be called when the installation process is Hook that will be called when the installation process is
finished and custom installation steps for specific default_profiles finished and custom installation steps for specific default_profiles
@ -131,7 +131,7 @@ class Profile:
""" """
return SelectResult.NewSelection return SelectResult.NewSelection
def set_custom_settings(self, settings: Dict[str, Any]): def set_custom_settings(self, settings: Dict[str, Any]) -> 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
@ -144,7 +144,7 @@ class Profile:
return [s.name for s in self.current_selection] return [s.name for s in self.current_selection]
return [] return []
def reset(self): def reset(self) -> None:
self.current_selection = [] self.current_selection = []
def is_top_level_profile(self) -> bool: def is_top_level_profile(self) -> bool:

View File

@ -4,7 +4,7 @@ from archinstall.default_profiles.profile import Profile, ProfileType
class CockpitProfile(Profile): class CockpitProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Cockpit', 'Cockpit',
ProfileType.ServerType ProfileType.ServerType

View File

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class DockerProfile(Profile): class DockerProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Docker', 'Docker',
ProfileType.ServerType ProfileType.ServerType
@ -24,7 +24,7 @@ class DockerProfile(Profile):
def services(self) -> List[str]: def services(self) -> List[str]:
return ['docker'] return ['docker']
def post_install(self, install_session: 'Installer'): def post_install(self, install_session: 'Installer') -> None:
users: Union[User, List[User]] = archinstall.arguments.get('!users', []) users: Union[User, List[User]] = archinstall.arguments.get('!users', [])
if not isinstance(users, list): if not isinstance(users, list):
users = [users] users = [users]

View File

@ -4,7 +4,7 @@ from archinstall.default_profiles.profile import Profile, ProfileType
class HttpdProfile(Profile): class HttpdProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'httpd', 'httpd',
ProfileType.ServerType ProfileType.ServerType

View File

@ -4,7 +4,7 @@ from archinstall.default_profiles.profile import Profile, ProfileType
class LighttpdProfile(Profile): class LighttpdProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Lighttpd', 'Lighttpd',
ProfileType.ServerType ProfileType.ServerType

View File

@ -7,7 +7,7 @@ if TYPE_CHECKING:
class MariadbProfile(Profile): class MariadbProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Mariadb', 'Mariadb',
ProfileType.ServerType ProfileType.ServerType
@ -21,5 +21,5 @@ class MariadbProfile(Profile):
def services(self) -> List[str]: def services(self) -> List[str]:
return ['mariadb'] return ['mariadb']
def post_install(self, install_session: 'Installer'): def post_install(self, install_session: 'Installer') -> None:
install_session.arch_chroot('mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql') install_session.arch_chroot('mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql')

View File

@ -4,7 +4,7 @@ from archinstall.default_profiles.profile import Profile, ProfileType
class NginxProfile(Profile): class NginxProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Nginx', 'Nginx',
ProfileType.ServerType ProfileType.ServerType

View File

@ -7,7 +7,7 @@ if TYPE_CHECKING:
class PostgresqlProfile(Profile): class PostgresqlProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Postgresql', 'Postgresql',
ProfileType.ServerType, ProfileType.ServerType,
@ -22,5 +22,5 @@ class PostgresqlProfile(Profile):
def services(self) -> List[str]: def services(self) -> List[str]:
return ['postgresql'] return ['postgresql']
def post_install(self, install_session: 'Installer'): def post_install(self, install_session: 'Installer') -> None:
install_session.arch_chroot("initdb -D /var/lib/postgres/data", run_as='postgres') install_session.arch_chroot("initdb -D /var/lib/postgres/data", run_as='postgres')

View File

@ -4,7 +4,7 @@ from archinstall.default_profiles.profile import Profile, ProfileType
class SshdProfile(Profile): class SshdProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'sshd', 'sshd',
ProfileType.ServerType ProfileType.ServerType

View File

@ -4,7 +4,7 @@ from archinstall.default_profiles.profile import Profile, ProfileType
class TomcatProfile(Profile): class TomcatProfile(Profile):
def __init__(self): def __init__(self) -> None:
super().__init__( super().__init__(
'Tomcat', 'Tomcat',
ProfileType.ServerType ProfileType.ServerType

View File

@ -9,13 +9,13 @@ if TYPE_CHECKING:
class TailoredProfile(XorgProfile): class TailoredProfile(XorgProfile):
def __init__(self): def __init__(self) -> None:
super().__init__('52-54-00-12-34-56', ProfileType.Tailored, description='') super().__init__('52-54-00-12-34-56', ProfileType.Tailored, description='')
@property @property
def packages(self) -> List[str]: def packages(self) -> List[str]:
return ['nano', 'wget', 'git'] return ['nano', 'wget', 'git']
def install(self, install_session: 'Installer'): def install(self, install_session: 'Installer') -> None:
super().install(install_session) super().install(install_session)
# do whatever you like here :) # do whatever you like here :)