Skip to content

Commit c494957

Browse files
author
Radjammin@gmail.com
committed
pylint error resolved
1 parent ef785ea commit c494957

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

tools/check-translations.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,20 @@
4949
PLACEHOLDER_RE = re.compile(r"%\d+")
5050
HTML_TAG_RE = re.compile(r"<[^>]+>")
5151

52-
# ANSI escape codes (Globals)
53-
BOLD, CYAN, YELLOW, RED, RESET = "\033[1m", "\033[36m", "\033[33m", "\033[31m", "\033[0m"
52+
53+
class Colors:
54+
"""ANSI escape codes for terminal output."""
55+
BOLD = "\033[1m"
56+
CYAN = "\033[36m"
57+
YELLOW = "\033[33m"
58+
RED = "\033[31m"
59+
RESET = "\033[0m"
5460

5561

5662
def configure_colors(color_arg: str):
5763
"""Disable color constants if outputting to a non-TTY without 'always' override."""
58-
global BOLD, CYAN, YELLOW, RED, RESET
5964
if color_arg == 'never' or (color_arg == 'auto' and not sys.stdout.isatty()):
60-
BOLD = CYAN = YELLOW = RED = RESET = ""
65+
Colors.BOLD = Colors.CYAN = Colors.YELLOW = Colors.RED = Colors.RESET = ""
6166

6267

6368
class Severity(IntEnum):
@@ -214,11 +219,11 @@ def detect_warnings(ts_file: Path, file_lang: str):
214219

215220
def _print_results(grouped):
216221
for file in sorted(grouped.keys()):
217-
print(f"\n{BOLD}File: {file.name}{RESET}")
222+
print(f"\n{Colors.BOLD}File: {file.name}{Colors.RESET}")
218223
for w in sorted(grouped[file], key=lambda x: x.line):
219-
color, sev = (RED, "SEVERE ") if w.severity == Severity.SEVERE else (YELLOW, "WARNING")
224+
color, sev = (Colors.RED, "SEVERE ") if w.severity == Severity.SEVERE else (Colors.YELLOW, "WARNING")
220225
lines = w.message.split("\n")
221-
print(f" {CYAN}Line {w.line:<4}{RESET} | {color}{sev}{RESET} | {lines[0]}")
226+
print(f" {Colors.CYAN}Line {w.line:<4}{Colors.RESET} | {color}{sev}{Colors.RESET} | {lines[0]}")
222227
for extra in lines[1:]:
223228
print(f" | | {extra}")
224229

@@ -252,7 +257,7 @@ def main():
252257

253258
print("\n== Test Summary ==")
254259
for lang in sorted(stats.keys()):
255-
print(f"{BOLD}[{lang}]{RESET} Severe: {stats[lang]['severe']}, "
260+
print(f"{Colors.BOLD}[{lang}]{Colors.RESET} Severe: {stats[lang]['severe']}, "
256261
f"Warnings: {stats[lang]['warning']}")
257262

258263
if sum(s["severe"] for s in stats.values()) > 0 or (

0 commit comments

Comments
 (0)