Skip to content

Commit 8f7d59b

Browse files
authored
Replace __enter__ return type with Self (archlinux#4121)
1 parent b779345 commit 8f7d59b

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

archinstall/lib/boot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import time
22
from collections.abc import Iterator
33
from types import TracebackType
4+
from typing import Self
45

56
from .exceptions import SysCallError
67
from .general import SysCommand, SysCommandWorker, locate_binary
@@ -16,7 +17,7 @@ def __init__(self, installation: Installer):
1617
self.session: SysCommandWorker | None = None
1718
self.ready = False
1819

19-
def __enter__(self) -> 'Boot':
20+
def __enter__(self) -> Self:
2021
if (existing_session := storage.get('active_boot', None)) and existing_session.instance != self.instance:
2122
raise KeyError('Archinstall only supports booting up one instance and another session is already active.')
2223

archinstall/lib/general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from select import EPOLLHUP, EPOLLIN, epoll
1616
from shutil import which
1717
from types import TracebackType
18-
from typing import Any, override
18+
from typing import Any, Self, override
1919

2020
from .exceptions import RequirementError, SysCallError
2121
from .output import debug, error, logger
@@ -177,7 +177,7 @@ def __str__(self) -> str:
177177
except UnicodeDecodeError:
178178
return str(self._trace_log)
179179

180-
def __enter__(self) -> 'SysCommandWorker':
180+
def __enter__(self) -> Self:
181181
return self
182182

183183
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:

archinstall/lib/installer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pathlib import Path
1212
from subprocess import CalledProcessError
1313
from types import TracebackType
14-
from typing import Any
14+
from typing import Any, Self
1515

1616
from archinstall.lib.disk.device_handler import device_handler
1717
from archinstall.lib.disk.fido import Fido2
@@ -123,7 +123,7 @@ def __init__(
123123

124124
self.pacman = Pacman(self.target, arch_config_handler.args.silent)
125125

126-
def __enter__(self) -> 'Installer':
126+
def __enter__(self) -> Self:
127127
return self
128128

129129
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None:

0 commit comments

Comments
 (0)