Replace __enter__ return type with Self (#4121)
This commit is contained in:
parent
b779345a5b
commit
8f7d59b718
|
|
@ -1,6 +1,7 @@
|
||||||
import time
|
import time
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
|
from typing import Self
|
||||||
|
|
||||||
from .exceptions import SysCallError
|
from .exceptions import SysCallError
|
||||||
from .general import SysCommand, SysCommandWorker, locate_binary
|
from .general import SysCommand, SysCommandWorker, locate_binary
|
||||||
|
|
@ -16,7 +17,7 @@ class Boot:
|
||||||
self.session: SysCommandWorker | None = None
|
self.session: SysCommandWorker | None = None
|
||||||
self.ready = False
|
self.ready = False
|
||||||
|
|
||||||
def __enter__(self) -> 'Boot':
|
def __enter__(self) -> Self:
|
||||||
if (existing_session := storage.get('active_boot', None)) and existing_session.instance != self.instance:
|
if (existing_session := storage.get('active_boot', None)) and existing_session.instance != self.instance:
|
||||||
raise KeyError('Archinstall only supports booting up one instance and another session is already active.')
|
raise KeyError('Archinstall only supports booting up one instance and another session is already active.')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ from pathlib import Path
|
||||||
from select import EPOLLHUP, EPOLLIN, epoll
|
from select import EPOLLHUP, EPOLLIN, epoll
|
||||||
from shutil import which
|
from shutil import which
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any, override
|
from typing import Any, Self, override
|
||||||
|
|
||||||
from .exceptions import RequirementError, SysCallError
|
from .exceptions import RequirementError, SysCallError
|
||||||
from .output import debug, error, logger
|
from .output import debug, error, logger
|
||||||
|
|
@ -177,7 +177,7 @@ class SysCommandWorker:
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return str(self._trace_log)
|
return str(self._trace_log)
|
||||||
|
|
||||||
def __enter__(self) -> 'SysCommandWorker':
|
def __enter__(self) -> Self:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
|
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ from collections.abc import Callable
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any
|
from typing import Any, Self
|
||||||
|
|
||||||
from archinstall.lib.disk.device_handler import device_handler
|
from archinstall.lib.disk.device_handler import device_handler
|
||||||
from archinstall.lib.disk.fido import Fido2
|
from archinstall.lib.disk.fido import Fido2
|
||||||
|
|
@ -123,7 +123,7 @@ class Installer:
|
||||||
|
|
||||||
self.pacman = Pacman(self.target, arch_config_handler.args.silent)
|
self.pacman = Pacman(self.target, arch_config_handler.args.silent)
|
||||||
|
|
||||||
def __enter__(self) -> 'Installer':
|
def __enter__(self) -> Self:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None:
|
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue