diff --git a/pylib/gyp/MSVSSettings.py b/pylib/gyp/MSVSSettings.py index e89a971a..93633dbc 100644 --- a/pylib/gyp/MSVSSettings.py +++ b/pylib/gyp/MSVSSettings.py @@ -141,7 +141,7 @@ class _Boolean(_Type): """Boolean settings, can have the values 'false' or 'true'.""" def _Validate(self, value): - if value != "true" and value != "false": + if value not in {"true", "false"}: raise ValueError("expected bool; got %r" % value) def ValidateMSVS(self, value): diff --git a/pylib/gyp/generator/analyzer.py b/pylib/gyp/generator/analyzer.py index 1d04d3fc..1334f2fc 100644 --- a/pylib/gyp/generator/analyzer.py +++ b/pylib/gyp/generator/analyzer.py @@ -379,7 +379,7 @@ def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files, build target.is_executable = target_type == "executable" target.is_static_library = target_type == "static_library" target.is_or_has_linked_ancestor = ( - target_type == "executable" or target_type == "shared_library" + target_type in {"executable", "shared_library"} ) build_file = gyp.common.ParseQualifiedTarget(target_name)[0] @@ -451,8 +451,8 @@ def _DoesTargetDependOnMatchingTargets(target): if target.match_status == MATCH_STATUS_DOESNT_MATCH: return False if ( - target.match_status == MATCH_STATUS_MATCHES - or target.match_status == MATCH_STATUS_MATCHES_BY_DEPENDENCY + target.match_status in {MATCH_STATUS_MATCHES, + MATCH_STATUS_MATCHES_BY_DEPENDENCY} ): return True for dep in target.deps: diff --git a/pylib/gyp/generator/android.py b/pylib/gyp/generator/android.py index cdf1a483..d3c97c66 100644 --- a/pylib/gyp/generator/android.py +++ b/pylib/gyp/generator/android.py @@ -697,7 +697,7 @@ def ComputeOutputParts(self, spec): target, ) - if self.type != "static_library" and self.type != "shared_library": + if self.type not in {"static_library", "shared_library"}: target_prefix = spec.get("product_prefix", target_prefix) target = spec.get("product_name", target) product_ext = spec.get("product_extension") diff --git a/pylib/gyp/generator/make.py b/pylib/gyp/generator/make.py index b4be3d79..1b997494 100644 --- a/pylib/gyp/generator/make.py +++ b/pylib/gyp/generator/make.py @@ -1063,7 +1063,7 @@ def WriteActions( # libraries, but until everything is made cross-compile safe, also use # target libraries. # TODO(piman): when everything is cross-compile safe, remove lib.target - if self.flavor == "zos" or self.flavor == "aix": + if self.flavor in {"zos", "aix"}: self.WriteLn( "cmd_%s = LIBPATH=$(builddir)/lib.host:" "$(builddir)/lib.target:$$LIBPATH; " @@ -2028,7 +2028,7 @@ def WriteTarget( installable_deps.append( self.GetUnversionedSidedeckFromSidedeck(install_path) ) - if self.output != self.alias and self.alias != self.target: + if self.alias not in (self.output, self.target): self.WriteMakeRule( [self.alias], installable_deps, diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py index b6464e98..c359431c 100644 --- a/pylib/gyp/input.py +++ b/pylib/gyp/input.py @@ -1576,14 +1576,12 @@ def ExpandWildcardDependencies(targets, data): continue dependency_target_name = dependency_target_dict["target_name"] if ( - dependency_target != "*" - and dependency_target != dependency_target_name + dependency_target not in {"*", dependency_target_name} ): continue dependency_target_toolset = dependency_target_dict["toolset"] if ( - dependency_toolset != "*" - and dependency_toolset != dependency_target_toolset + dependency_toolset not in {"*", dependency_target_toolset} ): continue dependency = gyp.common.QualifiedTarget( @@ -2541,7 +2539,7 @@ def ProcessListFiltersInDict(name, the_dict): del_lists = [] for key, value in the_dict.items(): operation = key[-1] - if operation != "!" and operation != "/": + if operation not in {"!", "/"}: continue if type(value) is not list: diff --git a/pylib/gyp/xcodeproj_file.py b/pylib/gyp/xcodeproj_file.py index fe7c3dfc..33c667c2 100644 --- a/pylib/gyp/xcodeproj_file.py +++ b/pylib/gyp/xcodeproj_file.py @@ -971,7 +971,7 @@ def __init__(self, properties=None, id=None, parent=None): if "path" in self._properties and "name" not in self._properties: path = self._properties["path"] name = posixpath.basename(path) - if name != "" and path != name: + if name not in ("", path): self.SetProperty("name", name) if "path" in self._properties and ( @@ -2546,10 +2546,10 @@ def __init__( force_extension = suffix[1:] if ( - self._properties["productType"] - == "com.apple.product-type-bundle.unit.test" - or self._properties["productType"] - == "com.apple.product-type-bundle.ui-testing" + self._properties["productType"] in { + "com.apple.product-type-bundle.unit.test", + "com.apple.product-type-bundle.ui-testing" + } ) and force_extension is None: force_extension = suffix[1:] @@ -2700,8 +2700,10 @@ def AddDependency(self, other): other._properties["productType"] == static_library_type or ( ( - other._properties["productType"] == shared_library_type - or other._properties["productType"] == framework_type + other._properties["productType"] in { + shared_library_type, + framework_type + } ) and ( (not other.HasBuildSetting("MACH_O_TYPE")) diff --git a/pyproject.toml b/pyproject.toml index 3c4020b2..7e11d2bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,12 +86,14 @@ select = [ # "TRY", # tryceratops ] ignore = [ + "E721", "PLC1901", "PLR0402", "PLR2004", "PLR5501", "PLW0603", "PLW2901", + "PYI024", "RUF005", "RUF012", "UP031",