From 4295f4491e711fdd88b82d596faba87a6fb1316d Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Mon, 19 May 2025 11:41:41 -0400 Subject: [PATCH] Remove remaining bare _ translation references This helps simplify the linter configs and improves compatibility with type checkers. --- .flake8 | 1 - archinstall/lib/translationhandler.py | 14 +++++++------- pyproject.toml | 2 -- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.flake8 b/.flake8 index 6ca7c045a1..d45a2ce87d 100644 --- a/.flake8 +++ b/.flake8 @@ -5,5 +5,4 @@ max-complexity = 40 max-line-length = 160 show-source = True statistics = True -builtins = _ exclude = .git,__pycache__,build,docs,actions-runner diff --git a/archinstall/lib/translationhandler.py b/archinstall/lib/translationhandler.py index f557b82389..f058cf87c8 100644 --- a/archinstall/lib/translationhandler.py +++ b/archinstall/lib/translationhandler.py @@ -6,10 +6,7 @@ import os from dataclasses import dataclass from pathlib import Path -from typing import TYPE_CHECKING, Any, override - -if TYPE_CHECKING: - _: Any +from typing import override @dataclass @@ -136,6 +133,7 @@ def activate(self, language: Language) -> None: """ Set the provided language as the current translation """ + # The install() call has the side effect of assigning GNUTranslations.gettext to builtins._ language.translation.install() def _get_locales_dir(self) -> Path: @@ -170,10 +168,12 @@ def __len__(self) -> int: @override def __str__(self) -> str: - translate = _ - if translate is _DeferredTranslation: + if builtins._ is _DeferredTranslation: # type: ignore[attr-defined] return self.message - return translate(self.message) + + # builtins._ is changed from _DeferredTranslation to GNUTranslations.gettext after + # Language.activate() is called + return builtins._(self.message) # type: ignore[attr-defined] def __lt__(self, other) -> bool: return self.message < other diff --git a/pyproject.toml b/pyproject.toml index e50480d0c2..cd8acbf507 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -171,12 +171,10 @@ disable = [ score = false [tool.pylint.variables] -additional-builtins = ["_"] init-import = true [tool.ruff] target-version = "py312" -builtins = ["_"] line-length = 160 [tool.ruff.format]