Skip to content

Commit

Permalink
Fix lint: ruff check --select=UP032 --fix (#2994)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Mar 13, 2024
1 parent fbf3fda commit 1205fb0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
6 changes: 3 additions & 3 deletions gyp/pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,9 @@ def ComputeOutput(self, spec):
% (self.android_class, self.android_module)
)
else:
path = "$(call intermediates-dir-for,{},{},,,$(GYP_VAR_PREFIX))".format(
self.android_class,
self.android_module,
path = (
"$(call intermediates-dir-for,"
f"{self.android_class},{self.android_module},,,$(GYP_VAR_PREFIX))"
)

assert spec.get("product_dir") is None # TODO: not supported?
Expand Down
7 changes: 3 additions & 4 deletions gyp/pylib/gyp/generator/gypsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
# Use a banner that looks like the stock Python one and like what
# code.interact uses by default, but tack on something to indicate what
# locals are available, and identify gypsh.
banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format(
sys.version,
sys.platform,
repr(sorted(locals.keys())),
banner = (
f"Python {sys.version} on {sys.platform}\nlocals.keys() = "
f"{repr(sorted(locals.keys()))}\ngypsh"
)

code.interact(banner, local=locals)
20 changes: 8 additions & 12 deletions gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,11 +1778,9 @@ def _GetCopies(spec):
outer_dir = posixpath.split(src_bare)[1]
fixed_dst = _FixPath(dst)
full_dst = f'"{fixed_dst}\\{outer_dir}\\"'
cmd = 'mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}'.format(
full_dst,
_FixPath(base_dir),
outer_dir,
full_dst,
cmd = (
f'mkdir {full_dst} 2>nul & cd "{_FixPath(base_dir)}" && '
f'xcopy /e /f /y "{outer_dir}" {full_dst}'
)
copies.append(
(
Expand All @@ -1794,10 +1792,9 @@ def _GetCopies(spec):
)
else:
fix_dst = _FixPath(cpy["destination"])
cmd = 'mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}"'.format(
fix_dst,
_FixPath(src),
_FixPath(dst),
cmd = (
f'mkdir "{fix_dst}" 2>nul & set ERRORLEVEL=0 & '
f'copy /Y "{_FixPath(src)}" "{_FixPath(dst)}"'
)
copies.append(([src], [dst], cmd, f"Copying {src} to {fix_dst}"))
return copies
Expand Down Expand Up @@ -1899,9 +1896,8 @@ def _GetPlatformOverridesOfProject(spec):
for config_name, c in spec["configurations"].items():
config_fullname = _ConfigFullName(config_name, c)
platform = c.get("msvs_target_platform", _ConfigPlatform(c))
fixed_config_fullname = "{}|{}".format(
_ConfigBaseName(config_name, _ConfigPlatform(c)),
platform,
fixed_config_fullname = (
f"{_ConfigBaseName(config_name, _ConfigPlatform(c))}|{platform}"
)
if spec["toolset"] == "host" and generator_supports_multiple_toolsets:
fixed_config_fullname = f"{config_name}|x64"
Expand Down
10 changes: 4 additions & 6 deletions gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,18 +1135,16 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file):
true_dict = condition[i + 1]
if type(true_dict) is not dict:
raise GypError(
"{} {} must be followed by a dictionary, not {}".format(
conditions_key, cond_expr, type(true_dict)
)
f"{conditions_key} {cond_expr} must be followed by a dictionary, not "
f"{type(true_dict)}"
)
if len(condition) > i + 2 and type(condition[i + 2]) is dict:
false_dict = condition[i + 2]
i = i + 3
if i != len(condition):
raise GypError(
"{} {} has {} unexpected trailing items".format(
conditions_key, cond_expr, len(condition) - i
)
f"{conditions_key} {cond_expr} has {len(condition) - i} "
"unexpected trailing items"
)
else:
false_dict = None
Expand Down
9 changes: 3 additions & 6 deletions gyp/pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,14 @@ def _GetLdManifestFlags(
("VCLinkerTool", "UACUIAccess"), config, default="false"
)

inner = """
inner = f"""
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='{}' uiAccess='{}' />
<requestedExecutionLevel level='{execution_level_map[execution_level]}' uiAccess='{ui_access}' />
</requestedPrivileges>
</security>
</trustInfo>""".format(
execution_level_map[execution_level],
ui_access,
)
</trustInfo>""" # noqa: E501
else:
inner = ""

Expand Down
8 changes: 4 additions & 4 deletions gyp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gyp = "gyp:script_main"
"Homepage" = "https://github.com/nodejs/gyp-next"

[tool.ruff]
select = [
lint.select = [
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"DTZ", # flake8-datetimez
Expand Down Expand Up @@ -87,7 +87,7 @@ select = [
# "T20", # flake8-print
# "TRY", # tryceratops
]
ignore = [
lint.ignore = [
"E721",
"PLC1901",
"PLR0402",
Expand All @@ -105,10 +105,10 @@ extend-exclude = ["pylib/packaging"]
line-length = 88
target-version = "py37"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 101

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
max-args = 11
max-branches = 108
max-returns = 10
Expand Down

0 comments on commit 1205fb0

Please sign in to comment.