Remove remaining bare _ translation references (#3485)
This helps simplify the linter configs and improves compatibility with type checkers.
This commit is contained in:
parent
a945606834
commit
3e5f879d52
1
.flake8
1
.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
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ import json
|
|||
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 @@ class TranslationHandler:
|
|||
"""
|
||||
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 @@ class _DeferredTranslation:
|
|||
|
||||
@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
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in New Issue