Upgrade mypy 1.11 (#2588)

* Upgrade mypy 1.11

* Update

* Update

* Remove TProfile type
This commit is contained in:
Daniel Girtler 2024-07-27 07:23:47 +10:00 committed by GitHub
parent 494cc29a3f
commit 32bc37545e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 28 additions and 36 deletions

View File

@ -55,7 +55,7 @@ class DesktopProfile(Profile):
def do_on_select(self) -> SelectResult:
choice = profile_handler.select_profile(
profile_handler.get_desktop_profiles(),
self._current_selection,
self.current_selection,
title=str(_('Select your desired desktop environment')),
multi=True
)
@ -71,14 +71,14 @@ class DesktopProfile(Profile):
return SelectResult.ResetCurrent
def post_install(self, install_session: 'Installer'):
for profile in self._current_selection:
for profile in self.current_selection:
profile.post_install(install_session)
def install(self, install_session: 'Installer'):
# Install common packages for all desktop environments
install_session.add_additional_packages(self.packages)
for profile in self._current_selection:
for profile in self.current_selection:
info(f'Installing profile {profile.name}...')
install_session.add_additional_packages(profile.packages)

View File

@ -1,7 +1,7 @@
from __future__ import annotations
from enum import Enum, auto
from typing import List, Optional, Any, Dict, TYPE_CHECKING, TypeVar
from typing import List, Optional, Any, Dict, TYPE_CHECKING
from archinstall.lib.utils.util import format_cols
@ -10,9 +10,6 @@ if TYPE_CHECKING:
_: Any
TProfile = TypeVar('TProfile', bound='Profile')
class ProfileType(Enum):
# top level default_profiles
Server = 'Server'
@ -50,7 +47,7 @@ class Profile:
name: str,
profile_type: ProfileType,
description: str = '',
current_selection: List[TProfile] = [],
current_selection: List[Profile] = [],
packages: List[str] = [],
services: List[str] = [],
support_gfx_driver: bool = False,
@ -66,17 +63,13 @@ class Profile:
# self.gfx_driver: Optional[str] = None
self._current_selection = current_selection
self.current_selection = current_selection
self._packages = packages
self._services = services
# Only used for custom default_profiles
self.custom_enabled = False
@property
def current_selection(self) -> List[TProfile]:
return self._current_selection
@property
def packages(self) -> List[str]:
"""
@ -133,15 +126,12 @@ class Profile:
self.custom_settings = settings
def current_selection_names(self) -> List[str]:
if self._current_selection:
return [s.name for s in self._current_selection]
if self.current_selection:
return [s.name for s in self.current_selection]
return []
def reset(self):
self.set_current_selection([])
def set_current_selection(self, current_selection: List[TProfile]):
self._current_selection = current_selection
self.current_selection = []
def is_top_level_profile(self) -> bool:
top_levels = [ProfileType.Desktop, ProfileType.Server, ProfileType.Xorg, ProfileType.Minimal, ProfileType.Custom]
@ -166,10 +156,10 @@ class Profile:
return self.profile_type == ProfileType.CustomType
def is_graphic_driver_supported(self) -> bool:
if not self._current_selection:
if not self.current_selection:
return self._support_gfx_driver
else:
if any([p._support_gfx_driver for p in self._current_selection]):
if any([p._support_gfx_driver for p in self.current_selection]):
return True
return False

View File

@ -3,7 +3,7 @@ from typing import Any, TYPE_CHECKING, List
from archinstall.lib.output import info
from archinstall.lib.menu import MenuSelectionType
from archinstall.lib.profile.profiles_handler import profile_handler
from archinstall.default_profiles.profile import ProfileType, Profile, SelectResult, TProfile
from archinstall.default_profiles.profile import ProfileType, Profile, SelectResult
if TYPE_CHECKING:
from archinstall.lib.installer import Installer
@ -11,7 +11,7 @@ if TYPE_CHECKING:
class ServerProfile(Profile):
def __init__(self, current_value: List[TProfile] = []):
def __init__(self, current_value: List[Profile] = []):
super().__init__(
'Server',
ProfileType.Server,
@ -24,7 +24,7 @@ class ServerProfile(Profile):
choice = profile_handler.select_profile(
available_servers,
self._current_selection,
self.current_selection,
title=str(_('Choose which servers to install, if none then a minimal installation will be done')),
multi=True
)
@ -38,16 +38,16 @@ class ServerProfile(Profile):
case MenuSelectionType.Reset:
return SelectResult.ResetCurrent
def post_install(self, install_session: 'Installer'):
for profile in self._current_selection:
def post_install(self, install_session: 'Installer') -> None:
for profile in self.current_selection:
profile.post_install(install_session)
def install(self, install_session: 'Installer'):
def install(self, install_session: 'Installer') -> None:
server_info = self.current_selection_names()
details = ', '.join(server_info)
info(f'Now installing the selected servers: {details}')
for server in self._current_selection:
for server in self.current_selection:
info(f'Installing {server.name}...')
install_session.add_additional_packages(server.packages)
install_session.enable_service(server.services)

View File

@ -5,18 +5,20 @@ import unicodedata
from enum import Enum
from pathlib import Path
from typing import Dict, Union, List, Any, Callable, Optional
from typing import Dict, Union, List, Any, Callable, Optional, TYPE_CHECKING
from dataclasses import asdict, is_dataclass
from .storage import storage
if TYPE_CHECKING:
from _typeshed import DataclassInstance
class FormattedOutput:
@classmethod
def _get_values(
cls,
o: Any,
o: 'DataclassInstance',
class_formatter: Optional[Union[str, Callable]] = None,
filter_list: List[str] = []
) -> Dict[str, Any]:

View File

@ -10,7 +10,7 @@ from tempfile import NamedTemporaryFile
from types import ModuleType
from typing import List, TYPE_CHECKING, Any, Optional, Dict, Union
from archinstall.default_profiles.profile import Profile, TProfile, GreeterType
from archinstall.default_profiles.profile import Profile, GreeterType
from .profile_model import ProfileConfiguration
from ..hardware import GfxDriver
from ..menu import MenuSelectionType, Menu, MenuSelection
@ -122,7 +122,7 @@ class ProfileHandler:
custom_settings = profile_config.get('custom_settings', {})
profile.set_custom_settings(custom_settings)
profile.set_current_selection(valid_sub_profiles)
profile.current_selection = valid_sub_profiles
return profile
@ -138,7 +138,7 @@ class ProfileHandler:
def _local_mac_addresses(self) -> List[str]:
return list(list_interfaces())
def add_custom_profiles(self, profiles: Union[TProfile, List[TProfile]]):
def add_custom_profiles(self, profiles: Union[Profile, List[Profile]]):
if not isinstance(profiles, list):
profiles = [profiles]
@ -147,7 +147,7 @@ class ProfileHandler:
self._verify_unique_profile_names(self.profiles)
def remove_custom_profiles(self, profiles: Union[TProfile, List[TProfile]]):
def remove_custom_profiles(self, profiles: Union[Profile, List[Profile]]):
if not isinstance(profiles, list):
profiles = [profiles]
@ -359,7 +359,7 @@ class ProfileHandler:
def select_profile(
self,
selectable_profiles: List[Profile],
current_profile: Optional[Union[TProfile, List[TProfile]]] = None,
current_profile: Optional[Union[Profile, List[Profile]]] = None,
title: str = '',
allow_reset: bool = True,
multi: bool = False,

View File

@ -30,7 +30,7 @@ Source = "https://github.com/archlinux/archinstall"
[project.optional-dependencies]
log = ["systemd_python==235"]
dev = [
"mypy==1.10.1",
"mypy==1.11.0",
"flake8==7.1.0",
"pre-commit==3.7.1",
]