Use Self for Tui (#4130)

This commit is contained in:
codefiles 2026-01-15 14:36:11 -05:00 committed by GitHub
parent 2c85b5eab0
commit 2c154245cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -9,7 +9,7 @@ from collections.abc import Callable
from curses.ascii import isprint from curses.ascii import isprint
from curses.textpad import Textbox from curses.textpad import Textbox
from types import FrameType, TracebackType from types import FrameType, TracebackType
from typing import Literal, override from typing import ClassVar, Literal, Self, override
from archinstall.lib.translationhandler import tr from archinstall.lib.translationhandler import tr
@ -1240,7 +1240,7 @@ class SelectMenu[ValueT](AbstractCurses[ValueT]):
class Tui: class Tui:
_t: Tui | None = None _t: ClassVar[Self | None] = None
def __enter__(self) -> None: def __enter__(self) -> None:
if Tui._t is None: if Tui._t is None:
@ -1254,10 +1254,10 @@ class Tui:
def screen(self) -> curses.window: def screen(self) -> curses.window:
return self._screen return self._screen
@staticmethod @classmethod
def t() -> 'Tui': def t(cls) -> Self:
assert Tui._t is not None assert cls._t is not None
return Tui._t return cls._t
@staticmethod @staticmethod
def shutdown() -> None: def shutdown() -> None:
@ -1266,7 +1266,7 @@ class Tui:
Tui.t().stop() Tui.t().stop()
def init(self) -> 'Tui': def init(self) -> Self:
self._screen = curses.initscr() self._screen = curses.initscr()
curses.noecho() curses.noecho()
curses.cbreak() curses.cbreak()