Fix lint: ruff check --select=UP032 --fix (#2994)

This commit is contained in:
Christian Clauss 2024-03-13 05:54:17 +01:00 committed by GitHub
parent fbf3fda875
commit 1205fb084c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 35 deletions

View file

@ -739,9 +739,9 @@ class AndroidMkWriter:
% (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?

View file

@ -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)

View file

@ -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(
(
@ -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
@ -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"

View file

@ -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

View file

@ -830,17 +830,14 @@ class MsvsSettings:
("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 = ""

View file

@ -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
@ -87,7 +87,7 @@ select = [
# "T20", # flake8-print
# "TRY", # tryceratops
]
ignore = [
lint.ignore = [
"E721",
"PLC1901",
"PLR0402",
@ -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