From 7041718909f50b4f1bfc5b39067cdb26a34d4e12 Mon Sep 17 00:00:00 2001 From: Softer Date: Tue, 28 Apr 2026 17:19:38 +0300 Subject: [PATCH] Remove Yes/No singleton cache on MenuItem MenuItem.yes() and .no() cached their first-call result on the class, so labels stayed stuck in the language active at first call. With the new locale-apply Confirmation firing right after a language switch this became user-visible. Drop the cache and construct fresh items per call - allocation cost is negligible and equality continues to work via the dataclass __eq__. --- archinstall/tui/ui/menu_item.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/archinstall/tui/ui/menu_item.py b/archinstall/tui/ui/menu_item.py index 4c10e275..ac198aa6 100644 --- a/archinstall/tui/ui/menu_item.py +++ b/archinstall/tui/ui/menu_item.py @@ -2,7 +2,7 @@ from collections.abc import Awaitable, Callable, Iterable from dataclasses import dataclass, field from enum import Enum from functools import cached_property -from typing import Any, ClassVar, Self, override +from typing import Any, Self, override from archinstall.lib.translationhandler import tr @@ -23,9 +23,6 @@ class MenuItem: _id: str = '' - _yes: ClassVar[Self | None] = None - _no: ClassVar[Self | None] = None - def __post_init__(self) -> None: if self.key is not None: self._id = self.key @@ -45,17 +42,11 @@ class MenuItem: @classmethod def yes(cls, action: Callable[[Any], Any] | None = None) -> Self: - if cls._yes is None: - cls._yes = cls(tr('Yes'), value=True, key='yes', action=action) - - return cls._yes + return cls(tr('Yes'), value=True, key='yes', action=action) @classmethod def no(cls, action: Callable[[Any], Any] | None = None) -> Self: - if cls._no is None: - cls._no = cls(tr('No'), value=False, key='no', action=action) - - return cls._no + return cls(tr('No'), value=False, key='no', action=action) def is_empty(self) -> bool: return self.text == '' or self.text is None