Skip to content

Commit 876ccaf

Browse files
authored
chore: update Ruff to 0.3.1 (#226)
- Fix new UP032 errors - Fix deprecated Ruff config structure
1 parent 7875642 commit 876ccaf

File tree

6 files changed

+30
-38
lines changed

6 files changed

+30
-38
lines changed

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+
f"$(call intermediates-dir-for,{self.android_class},"
744+
f"{self.android_module},,,$(GYP_VAR_PREFIX))"
745745
)
746746

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

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"{sorted(locals.keys())!r}\ngypsh"
5655
)
5756

5857
code.interact(banner, local=locals)

pylib/gyp/generator/msvs.py

Lines changed: 8 additions & 13 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,10 +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,
1905-
)
1899+
base_name = _ConfigBaseName(config_name, _ConfigPlatform(c))
1900+
fixed_config_fullname = f"{base_name}|{platform}"
19061901
if spec["toolset"] == "host" and generator_supports_multiple_toolsets:
19071902
fixed_config_fullname = f"{config_name}|x64"
19081903
config_platform_overrides[config_fullname] = fixed_config_fullname

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, "
1139+
f"not {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 "
1147+
f"{len(condition) - i} unexpected trailing items"
11501148
)
11511149
else:
11521150
false_dict = None

pylib/gyp/msvs_emulation.py

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

833-
inner = """
833+
level = execution_level_map[execution_level]
834+
inner = f"""
834835
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
835836
<security>
836837
<requestedPrivileges>
837-
<requestedExecutionLevel level='{}' uiAccess='{}' />
838+
<requestedExecutionLevel level='{level}' uiAccess='{ui_access}' />
838839
</requestedPrivileges>
839840
</security>
840-
</trustInfo>""".format(
841-
execution_level_map[execution_level],
842-
ui_access,
843-
)
841+
</trustInfo>"""
844842
else:
845843
inner = ""
846844

pyproject.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ classifiers = [
2929
]
3030

3131
[project.optional-dependencies]
32-
dev = ["flake8", "ruff == 0.3.0", "pytest"]
32+
dev = ["flake8", "ruff == 0.3.1", "pytest"]
3333

3434
[project.scripts]
3535
gyp = "gyp:script_main"
@@ -38,6 +38,11 @@ gyp = "gyp:script_main"
3838
"Homepage" = "https://github.com/nodejs/gyp-next"
3939

4040
[tool.ruff]
41+
extend-exclude = ["pylib/packaging"]
42+
line-length = 88
43+
target-version = "py37"
44+
45+
[tool.ruff.lint]
4146
select = [
4247
"C4", # flake8-comprehensions
4348
"C90", # McCabe cyclomatic complexity
@@ -101,14 +106,11 @@ ignore = [
101106
"RUF012",
102107
"UP031",
103108
]
104-
extend-exclude = ["pylib/packaging"]
105-
line-length = 88
106-
target-version = "py37"
107109

108-
[tool.ruff.mccabe]
110+
[tool.ruff.lint.mccabe]
109111
max-complexity = 101
110112

111-
[tool.ruff.pylint]
113+
[tool.ruff.lint.pylint]
112114
max-args = 11
113115
max-branches = 108
114116
max-returns = 10

0 commit comments

Comments
 (0)