Skip to content

Commit 5e12816

Browse files
committed
build: replace Python linter flake8 with ruff
1 parent 16afc86 commit 5e12816

10 files changed

Lines changed: 21 additions & 14 deletions

File tree

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ ignore = [
2727
"E7",
2828
"PLC1901",
2929
"RUF005",
30+
"RUF100",
3031
]
3132
line-length = 172
3233
target-version = "py37"
3334

3435
[tool.ruff.mccabe]
3536
max-complexity = 100
3637

38+
[tool.ruff.per-file-ignores]
39+
"tools/checkimports.py" = ["W605"]
40+
"tools/gyp/pylib/gyp/xcodeproj_file.py" = ["PLE0101"]
41+
"tools/icu/shrink-icu-src.py" = ["W605"]
42+
"tools/mkssldef.py" = ["W605"]
43+
3744
[tool.ruff.pylint]
3845
max-args = 12
3946
max-branches = 110

tools/checkimports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import itertools
99

1010
def do_exist(file_name, lines, imported):
11-
if not any(not re.match('using \\w+::{0};'.format(imported), line) and
11+
if not any(not re.match('using \w+::{0};'.format(imported), line) and
1212
re.search('\\b{0}\\b'.format(imported), line) for line in lines):
1313
print('File "{0}" does not use "{1}"'.format(file_name, imported))
1414
return False

tools/gyp/gyp_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def UnixifyPath(path):
3939
# else the 'gyp' library will not be found
4040
path = UnixifyPath(sys.argv[0])
4141
sys.path.insert(0, os.path.join(os.path.dirname(path), "pylib"))
42-
import gyp
42+
import gyp # noqa: E402
4343

4444
if __name__ == "__main__":
4545
sys.exit(gyp.script_main())

tools/gyp/pylib/gyp/generator/make.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def CalculateGeneratorInputInfo(params):
216216
217217
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
218218
cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
219-
"""
219+
""" # noqa: E501
220220

221221
LINK_COMMANDS_ANDROID = """\
222222
quiet_cmd_alink = AR($(TOOLSET)) $@
@@ -286,7 +286,7 @@ def CalculateGeneratorInputInfo(params):
286286
287287
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
288288
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
289-
"""
289+
""" # noqa: E501
290290

291291

292292
LINK_COMMANDS_OS400 = """\
@@ -304,7 +304,7 @@ def CalculateGeneratorInputInfo(params):
304304
305305
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
306306
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
307-
"""
307+
""" # noqa: E501
308308

309309

310310
LINK_COMMANDS_OS390 = """\
@@ -474,7 +474,7 @@ def CalculateGeneratorInputInfo(params):
474474
cmd_symlink = ln -sf "$<" "$@"
475475
476476
%(link_commands)s
477-
"""
477+
""" # noqa: E501
478478
r"""
479479
# Define an escape_quotes function to escape single quotes.
480480
# This allows us to handle quotes properly as long as we always use
@@ -573,7 +573,7 @@ def CalculateGeneratorInputInfo(params):
573573
.PHONY: FORCE_DO_CMD
574574
FORCE_DO_CMD:
575575
576-
"""
576+
""" # noqa: E501
577577
)
578578

579579
SHARED_HEADER_MAC_COMMANDS = """
@@ -604,7 +604,7 @@ def CalculateGeneratorInputInfo(params):
604604
605605
quiet_cmd_infoplist = INFOPLIST $@
606606
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
607-
"""
607+
""" # noqa: E501
608608

609609

610610
def WriteRootHeaderSuffixRules(writer):

tools/gyp/pylib/gyp/generator/msvs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def _EscapeEnvironmentVariableExpansion(s):
756756
757757
Returns:
758758
The escaped string.
759-
"""
759+
""" # noqa: E731,E123,E501
760760
s = s.replace("%", "%%")
761761
return s
762762

tools/gyp/pylib/gyp/generator/ninja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name
25332533
description="SOLINK $lib",
25342534
restat=True,
25352535
command=mtime_preserving_solink_base
2536-
% {"suffix": "@$link_file_list"},
2536+
% {"suffix": "@$link_file_list"}, # noqa: E501
25372537
rspfile="$link_file_list",
25382538
rspfile_content=(
25392539
"-Wl,--whole-archive $in $solibs -Wl," "--no-whole-archive $libs"

tools/gyp/pylib/gyp/xcode_emulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ def _GetXcodeEnv(
17331733
"CONFIGURATION": configuration,
17341734
"PRODUCT_NAME": xcode_settings.GetProductName(),
17351735
# For FULL_PRODUCT_NAME see:
1736-
# /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec
1736+
# /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec # noqa: E501
17371737
"SRCROOT": srcroot,
17381738
"SOURCE_ROOT": "${SRCROOT}",
17391739
# This is not true for static libraries, but currently the env is only

tools/gyp/pylib/gyp/xcodeproj_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ def __init__(self, properties=None, id=None, parent=None, path=None):
27702770
self.path = path
27712771
self._other_pbxprojects = {}
27722772
# super
2773-
XCContainerPortal.__init__(self, properties, id, parent)
2773+
return XCContainerPortal.__init__(self, properties, id, parent)
27742774

27752775
def Name(self):
27762776
name = self.path

tools/icu/shrink-icu-src.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def print_size(fn):
4848
size = (os.stat(fn).st_size) / 1024000
4949
print('%dM\t%s' % (size, fn))
5050

51-
ignore_regex = re.compile('^.*\\.(vcxproj|filters|nrm|icu|dat|xml|txt|ac|guess|m4|in|sub|py|mak)$')
51+
ignore_regex = re.compile('^.*\.(vcxproj|filters|nrm|icu|dat|xml|txt|ac|guess|m4|in|sub|py|mak)$')
5252

5353
def icu_ignore(dir, files):
5454
subdir = dir[len(options.icusrc)+1::]

tools/mkssldef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
for filename in filenames:
2828
for line in open(filename).readlines():
29-
name, _, _, meta, _ = re.split('\\s+', line)
29+
name, _, _, meta, _ = re.split('\s+', line)
3030
if any(p.match(name) for p in excludes): continue
3131
meta = meta.split(':')
3232
assert meta[0] in ('EXIST', 'NOEXIST')

0 commit comments

Comments
 (0)