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