Skip to content

Commit 1205fb0

Browse files
authored
Fix lint: ruff check --select=UP032 --fix (#2994)
1 parent fbf3fda commit 1205fb0

File tree

6 files changed

+25
-35
lines changed

6 files changed

+25
-35
lines changed

gyp/pylib/gyp/generator/android.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,9 @@ def ComputeOutput(self, spec):
739739
% (self.android_class, self.android_module)
740740
)
741741
else:
742-
path = "$(call intermediates-dir-for,{},{},,,$(GYP_VAR_PREFIX))".format(
743-
self.android_class,
744-
self.android_module,
742+
path = (
743+
"$(call intermediates-dir-for,"
744+
f"{self.android_class},{self.android_module},,,$(GYP_VAR_PREFIX))"
745745
)
746746

747747
assert spec.get("product_dir") is None # TODO: not supported?

gyp/pylib/gyp/generator/gypsh.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
4949
# Use a banner that looks like the stock Python one and like what
5050
# code.interact uses by default, but tack on something to indicate what
5151
# locals are available, and identify gypsh.
52-
banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format(
53-
sys.version,
54-
sys.platform,
55-
repr(sorted(locals.keys())),
52+
banner = (
53+
f"Python {sys.version} on {sys.platform}\nlocals.keys() = "
54+
f"{repr(sorted(locals.keys()))}\ngypsh"
5655
)
5756

5857
code.interact(banner, local=locals)

gyp/pylib/gyp/generator/msvs.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,11 +1778,9 @@ def _GetCopies(spec):
17781778
outer_dir = posixpath.split(src_bare)[1]
17791779
fixed_dst = _FixPath(dst)
17801780
full_dst = f'"{fixed_dst}\\{outer_dir}\\"'
1781-
cmd = 'mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}'.format(
1782-
full_dst,
1783-
_FixPath(base_dir),
1784-
outer_dir,
1785-
full_dst,
1781+
cmd = (
1782+
f'mkdir {full_dst} 2>nul & cd "{_FixPath(base_dir)}" && '
1783+
f'xcopy /e /f /y "{outer_dir}" {full_dst}'
17861784
)
17871785
copies.append(
17881786
(
@@ -1794,10 +1792,9 @@ def _GetCopies(spec):
17941792
)
17951793
else:
17961794
fix_dst = _FixPath(cpy["destination"])
1797-
cmd = 'mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}"'.format(
1798-
fix_dst,
1799-
_FixPath(src),
1800-
_FixPath(dst),
1795+
cmd = (
1796+
f'mkdir "{fix_dst}" 2>nul & set ERRORLEVEL=0 & '
1797+
f'copy /Y "{_FixPath(src)}" "{_FixPath(dst)}"'
18011798
)
18021799
copies.append(([src], [dst], cmd, f"Copying {src} to {fix_dst}"))
18031800
return copies
@@ -1899,9 +1896,8 @@ def _GetPlatformOverridesOfProject(spec):
18991896
for config_name, c in spec["configurations"].items():
19001897
config_fullname = _ConfigFullName(config_name, c)
19011898
platform = c.get("msvs_target_platform", _ConfigPlatform(c))
1902-
fixed_config_fullname = "{}|{}".format(
1903-
_ConfigBaseName(config_name, _ConfigPlatform(c)),
1904-
platform,
1899+
fixed_config_fullname = (
1900+
f"{_ConfigBaseName(config_name, _ConfigPlatform(c))}|{platform}"
19051901
)
19061902
if spec["toolset"] == "host" and generator_supports_multiple_toolsets:
19071903
fixed_config_fullname = f"{config_name}|x64"

gyp/pylib/gyp/input.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,18 +1135,16 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file):
11351135
true_dict = condition[i + 1]
11361136
if type(true_dict) is not dict:
11371137
raise GypError(
1138-
"{} {} must be followed by a dictionary, not {}".format(
1139-
conditions_key, cond_expr, type(true_dict)
1140-
)
1138+
f"{conditions_key} {cond_expr} must be followed by a dictionary, not "
1139+
f"{type(true_dict)}"
11411140
)
11421141
if len(condition) > i + 2 and type(condition[i + 2]) is dict:
11431142
false_dict = condition[i + 2]
11441143
i = i + 3
11451144
if i != len(condition):
11461145
raise GypError(
1147-
"{} {} has {} unexpected trailing items".format(
1148-
conditions_key, cond_expr, len(condition) - i
1149-
)
1146+
f"{conditions_key} {cond_expr} has {len(condition) - i} "
1147+
"unexpected trailing items"
11501148
)
11511149
else:
11521150
false_dict = None

gyp/pylib/gyp/msvs_emulation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,17 +830,14 @@ def _GetLdManifestFlags(
830830
("VCLinkerTool", "UACUIAccess"), config, default="false"
831831
)
832832

833-
inner = """
833+
inner = f"""
834834
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
835835
<security>
836836
<requestedPrivileges>
837-
<requestedExecutionLevel level='{}' uiAccess='{}' />
837+
<requestedExecutionLevel level='{execution_level_map[execution_level]}' uiAccess='{ui_access}' />
838838
</requestedPrivileges>
839839
</security>
840-
</trustInfo>""".format(
841-
execution_level_map[execution_level],
842-
ui_access,
843-
)
840+
</trustInfo>""" # noqa: E501
844841
else:
845842
inner = ""
846843

gyp/pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ gyp = "gyp:script_main"
3838
"Homepage" = "https://github.com/nodejs/gyp-next"
3939

4040
[tool.ruff]
41-
select = [
41+
lint.select = [
4242
"C4", # flake8-comprehensions
4343
"C90", # McCabe cyclomatic complexity
4444
"DTZ", # flake8-datetimez
@@ -87,7 +87,7 @@ select = [
8787
# "T20", # flake8-print
8888
# "TRY", # tryceratops
8989
]
90-
ignore = [
90+
lint.ignore = [
9191
"E721",
9292
"PLC1901",
9393
"PLR0402",
@@ -105,10 +105,10 @@ extend-exclude = ["pylib/packaging"]
105105
line-length = 88
106106
target-version = "py37"
107107

108-
[tool.ruff.mccabe]
108+
[tool.ruff.lint.mccabe]
109109
max-complexity = 101
110110

111-
[tool.ruff.pylint]
111+
[tool.ruff.lint.pylint]
112112
max-args = 11
113113
max-branches = 108
114114
max-returns = 10

0 commit comments

Comments
 (0)