Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ max-complexity = 40
max-line-length = 160
show-source = True
statistics = True
builtins = _
exclude = .git,__pycache__,build,docs,actions-runner
14 changes: 7 additions & 7 deletions archinstall/lib/translationhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down