From 1205fb084c0ed571429cf2ab12e885788be68e5f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 13 Mar 2024 05:54:17 +0100 Subject: [PATCH] Fix lint: ruff check --select=UP032 --fix (#2994) --- gyp/pylib/gyp/generator/android.py | 6 +++--- gyp/pylib/gyp/generator/gypsh.py | 7 +++---- gyp/pylib/gyp/generator/msvs.py | 20 ++++++++------------ gyp/pylib/gyp/input.py | 10 ++++------ gyp/pylib/gyp/msvs_emulation.py | 9 +++------ gyp/pyproject.toml | 8 ++++---- 6 files changed, 25 insertions(+), 35 deletions(-) diff --git a/gyp/pylib/gyp/generator/android.py b/gyp/pylib/gyp/generator/android.py index d3c97c666d..9a79670214 100644 --- a/gyp/pylib/gyp/generator/android.py +++ b/gyp/pylib/gyp/generator/android.py @@ -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? diff --git a/gyp/pylib/gyp/generator/gypsh.py b/gyp/pylib/gyp/generator/gypsh.py index 82a07ddc65..625b6d65ca 100644 --- a/gyp/pylib/gyp/generator/gypsh.py +++ b/gyp/pylib/gyp/generator/gypsh.py @@ -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) diff --git a/gyp/pylib/gyp/generator/msvs.py b/gyp/pylib/gyp/generator/msvs.py index 13b0794b4d..6f0f8c1ab6 100644 --- a/gyp/pylib/gyp/generator/msvs.py +++ b/gyp/pylib/gyp/generator/msvs.py @@ -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" diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py index 8f39519dee..0b56c72750 100644 --- a/gyp/pylib/gyp/input.py +++ b/gyp/pylib/gyp/input.py @@ -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 diff --git a/gyp/pylib/gyp/msvs_emulation.py b/gyp/pylib/gyp/msvs_emulation.py index 38fa21dd66..847d1b8dc1 100644 --- a/gyp/pylib/gyp/msvs_emulation.py +++ b/gyp/pylib/gyp/msvs_emulation.py @@ -830,17 +830,14 @@ def _GetLdManifestFlags( ("VCLinkerTool", "UACUIAccess"), config, default="false" ) - inner = """ + inner = f""" - + -""".format( - execution_level_map[execution_level], - ui_access, - ) +""" # noqa: E501 else: inner = "" diff --git a/gyp/pyproject.toml b/gyp/pyproject.toml index 0c25d0b3c1..7183e07d3c 100644 --- a/gyp/pyproject.toml +++ b/gyp/pyproject.toml @@ -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