Skip to content

Commit 972a1a7

Browse files
committed
treewide: Fix ruff reported issues
1 parent 5e30bec commit 972a1a7

File tree

12 files changed

+35
-33
lines changed

12 files changed

+35
-33
lines changed

subprojects/packagefiles/lame/libmp3lame/fix_def.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22

3-
import os
43
import sys
54

65
with open(sys.argv[1], 'r') as f:

subprojects/packagefiles/libffi/meson-scripts/test-unwind-section.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import os
44
import sys
5-
import re
65
import subprocess
76

87
# Put output files in the builddir

subprojects/packagefiles/libuv/link_file_in_build_dir.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

3-
import os, sys
3+
import os
4+
import sys
45

56
filename = sys.argv[1]
67
linkname = sys.argv[2]

subprojects/packagefiles/m4/checks/m4_test_runner.py

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import sys
22
import subprocess
33
import os
4-
import tempfile
54

65
# We want to print line endings normally, but each line should be a b'' string
76
def clean(x):
87
lines = []
9-
for l in x.splitlines():
10-
if b'examples' in l:
11-
lines.append(str(l.replace(b'\\',b'/')))
8+
for line in x.splitlines():
9+
if b'examples' in line:
10+
lines.append(str(line.replace(b'\\',b'/')))
1211
else:
13-
lines.append(str(l))
12+
lines.append(str(line))
1413
return '\n'.join(lines)
1514

1615
def check_error(run_result,
@@ -45,29 +44,28 @@ def check_error(run_result,
4544
def main() -> int:
4645
m4_path = sys.argv[1]
4746
input_path = sys.argv[2]
48-
tmproot = sys.argv[3]
49-
workdir = sys.argv[4]
47+
workdir = sys.argv[3]
5048
examples_path = workdir + '/examples'
5149
if ':' in examples_path:
5250
examples_path = examples_path.partition(':')[2]
53-
with open(input_path, 'rb') as input_file, tempfile.TemporaryDirectory(dir=tmproot) as tmpdir:
51+
with open(input_path, 'rb') as input_file:
5452
expected_out = bytes()
5553
expected_err = bytes()
5654
ignore_err = False
5755
m4_input = bytes()
58-
for l in input_file.read().splitlines():
59-
if l.startswith(b'dnl @ expected status: '):
60-
expected_code = int(l[len('dnl @ expected status: '):].rstrip())
61-
if l.startswith(b'dnl @ extra options: '):
62-
args = l[len('dnl @ extra options: '):].rstrip().decode()
63-
if l.startswith(b'dnl @result{}'):
64-
expected_out += l[len('dnl @result{}'):] + os.linesep.encode()
65-
if l.startswith(b'dnl @error{}'):
66-
expected_err += l[len('dnl @error{}'):] + os.linesep.encode()
67-
if l.startswith(b'dnl @ expected error: ignore'):
56+
for line in input_file.read().splitlines():
57+
if line.startswith(b'dnl @ expected status: '):
58+
expected_code = int(line[len('dnl @ expected status: '):].rstrip())
59+
if line.startswith(b'dnl @ extra options: '):
60+
args = line[len('dnl @ extra options: '):].rstrip().decode()
61+
if line.startswith(b'dnl @result{}'):
62+
expected_out += line[len('dnl @result{}'):] + os.linesep.encode()
63+
if line.startswith(b'dnl @error{}'):
64+
expected_err += line[len('dnl @error{}'):] + os.linesep.encode()
65+
if line.startswith(b'dnl @ expected error: ignore'):
6866
ignore_err = True
69-
if not l.startswith(b'dnl @'):
70-
m4_input += l + b'\n'
67+
if not line.startswith(b'dnl @'):
68+
m4_input += line + b'\n'
7169
runargs = []
7270
runargs.append(m4_path)
7371
runargs.append('-d')

subprojects/packagefiles/m4/checks/meson.build

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,23 @@ m4_path = m4.full_path()
260260

261261
foreach file : checks
262262
test(file, py,
263-
args: [m4_test, m4_path, files(file), meson.current_build_dir(), meson.project_source_root()],
263+
args: [m4_test, m4_path, files(file), meson.project_source_root()],
264264
env: m4_env,
265265
depends: m4)
266266
endforeach
267267

268268
if host_machine.system() != 'windows'
269269
foreach file : noparallel_checks
270270
test(file, py,
271-
args: [m4_test, m4_path, files(file), meson.current_build_dir(), meson.project_source_root()],
271+
args: [m4_test, m4_path, files(file), meson.project_source_root()],
272272
depends: m4,
273273
env: m4_env,
274274
is_parallel: false)
275275
endforeach
276276

277277
foreach file : nowindows_checks
278278
test(file, py,
279-
args: [m4_test, m4_path, files(file), meson.current_build_dir(), meson.project_source_root()],
279+
args: [m4_test, m4_path, files(file), meson.project_source_root()],
280280
env: m4_env,
281281
depends: m4)
282282
endforeach

subprojects/packagefiles/openblas/gen_install_headers.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22
import argparse
3+
import re
34
from pathlib import Path
45

56
def write_openblas_config_header(dest_dir, version, config_last_path, template_path):
@@ -20,7 +21,7 @@ def write_openblas_config_header(dest_dir, version, config_last_path, template_p
2021
rest_of_line = " ".join(parts[1:]) if len(parts) > 1 else ""
2122
line_to_write = f"#define OPENBLAS_{macro_name} {rest_of_line}"
2223
f.write(f"{line_to_write.strip()}\n")
23-
24+
2425

2526
f.write(f'#define OPENBLAS_VERSION " OpenBLAS {version} "\n')
2627

@@ -101,3 +102,4 @@ def main():
101102

102103
if __name__ == "__main__":
103104
main()
105+

subprojects/packagefiles/sdl2/find-dylib-name.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import re
2121
import sys
2222
import pathlib
23+
import glob
2324

2425

2526
def verbose(*args):

subprojects/packagefiles/vo-aacenc/meson/makedef.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def output(platform, symbols):
127127
# Substitute prefix out
128128
dump = [re.sub(f'\s+{prefix}', ' ', x) for x in dump]
129129
# Substitute big chonky spaces out
130-
dump = [re.sub(f'\s+', ' ', x) for x in dump]
130+
dump = [re.sub('\s+', ' ', x) for x in dump]
131131
# Exclude blank lines
132132
dump = [x for x in dump if len(x) > 0]
133133
# Take only the *second* field (split by spaces)

tools/fake_tty.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22

3-
import os, pty, sys
3+
import os
4+
import pty
5+
import sys
46

57
os.environ['TERM'] = 'xterm-256color'
68
exit(os.waitstatus_to_exitcode(pty.spawn(sys.argv[1:])))

tools/import-wraps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_wrap_info(wrap: str) -> T.List[T.Tuple[str, str]]:
4040
version, revision = line.split()
4141
versions.append((version, revision))
4242
except subprocess.CalledProcessError:
43-
pass
43+
pass
4444
return versions
4545

4646
def rewrite_wrap(wrap: str):

tools/sanity_checks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
'glbinding-aux_export.h'
5353
],
5454
'godot-cpp' : [
55-
'meson-bindings-generator.py',
56-
],
55+
'meson-bindings-generator.py',
56+
],
5757
'gumbo-parser': [
5858
'tokenizer.cc',
5959
],

tools/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def is_linux() -> bool:
121121
return platform.system().lower() == 'linux'
122122

123123
def is_windows() -> bool:
124-
return platform.system().lower() == 'windows' and not "MSYSTEM" in os.environ
124+
return platform.system().lower() == 'windows' and "MSYSTEM" not in os.environ
125125

126126
def is_msys() -> bool:
127127
return platform.system().lower() == 'windows' and "MSYSTEM" in os.environ

0 commit comments

Comments
 (0)