Cleanup: suppress pylint/ruff warnings in Python scripts
This commit is contained in:
@@ -37,10 +37,8 @@ class _GetchUnix:
|
||||
|
||||
def __init__(self):
|
||||
import tty
|
||||
import sys
|
||||
|
||||
def __call__(self):
|
||||
import sys
|
||||
import tty
|
||||
import termios
|
||||
fd = sys.stdin.fileno()
|
||||
|
||||
@@ -210,14 +210,14 @@ def cmake_advanced_info() -> (
|
||||
def cmake_cache_var(var: str) -> str | None:
|
||||
with open(os.path.join(CMAKE_DIR, "CMakeCache.txt"), encoding='utf-8') as cache_file:
|
||||
lines = [
|
||||
l_strip for l in cache_file
|
||||
if (l_strip := l.strip())
|
||||
if not l_strip.startswith(("//", "#"))
|
||||
line_strip for line in cache_file
|
||||
if (line_strip := line.strip())
|
||||
if not line_strip.startswith(("//", "#"))
|
||||
]
|
||||
|
||||
for l in lines:
|
||||
if l.split(":")[0] == var:
|
||||
return l.split("=", 1)[-1]
|
||||
for line in lines:
|
||||
if line.split(":")[0] == var:
|
||||
return line.split("=", 1)[-1]
|
||||
return None
|
||||
|
||||
|
||||
@@ -234,8 +234,8 @@ def cmake_compiler_defines() -> list[str] | None:
|
||||
|
||||
os.system("%s -dM -E %s > %s" % (compiler, temp_c, temp_def))
|
||||
|
||||
with open(temp_def) as temp_def_fh:
|
||||
lines = [l.strip() for l in temp_def_fh if l.strip()]
|
||||
with open(temp_def, "r", encoding="utf-8") as temp_def_fh:
|
||||
lines = [line.strip() for line in temp_def_fh if line.strip()]
|
||||
|
||||
os.remove(temp_c)
|
||||
os.remove(temp_def)
|
||||
|
||||
@@ -109,16 +109,15 @@ def convert_tabs_to_spaces(files: Sequence[str]) -> None:
|
||||
|
||||
# Complex 2 space
|
||||
# because some comments have tabs for alignment.
|
||||
def handle(l: str) -> str:
|
||||
ls = l.lstrip("\t")
|
||||
d = len(l) - len(ls)
|
||||
def handle(line: str) -> str:
|
||||
line_strip = line.lstrip("\t")
|
||||
d = len(line) - len(line_strip)
|
||||
if d != 0:
|
||||
return (" " * d) + ls.expandtabs(4)
|
||||
else:
|
||||
return l.expandtabs(4)
|
||||
return (" " * d) + line_strip.expandtabs(4)
|
||||
return line.expandtabs(4)
|
||||
|
||||
lines = data.splitlines(keepends=True)
|
||||
lines = [handle(l) for l in lines]
|
||||
lines = [handle(line) for line in lines]
|
||||
data = "".join(lines)
|
||||
with open(f, 'w', encoding="utf-8") as fh:
|
||||
fh.write(data)
|
||||
|
||||
Reference in New Issue
Block a user