Skip to content

Commit f6af11a

Browse files
authored
Fix PLR1714 lint errors (#202)
* Fix PLR1714 lint errors * Add PLR to select * Remove PLR line * Fix another occurrence * Ignore newer lint rules * Fix another occurrence. Use tuples for now, too
1 parent 874233e commit f6af11a

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

pylib/gyp/MSVSSettings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class _Boolean(_Type):
141141
"""Boolean settings, can have the values 'false' or 'true'."""
142142

143143
def _Validate(self, value):
144-
if value != "true" and value != "false":
144+
if value not in {"true", "false"}:
145145
raise ValueError("expected bool; got %r" % value)
146146

147147
def ValidateMSVS(self, value):

pylib/gyp/generator/analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files, build
379379
target.is_executable = target_type == "executable"
380380
target.is_static_library = target_type == "static_library"
381381
target.is_or_has_linked_ancestor = (
382-
target_type == "executable" or target_type == "shared_library"
382+
target_type in {"executable", "shared_library"}
383383
)
384384

385385
build_file = gyp.common.ParseQualifiedTarget(target_name)[0]
@@ -451,8 +451,8 @@ def _DoesTargetDependOnMatchingTargets(target):
451451
if target.match_status == MATCH_STATUS_DOESNT_MATCH:
452452
return False
453453
if (
454-
target.match_status == MATCH_STATUS_MATCHES
455-
or target.match_status == MATCH_STATUS_MATCHES_BY_DEPENDENCY
454+
target.match_status in {MATCH_STATUS_MATCHES,
455+
MATCH_STATUS_MATCHES_BY_DEPENDENCY}
456456
):
457457
return True
458458
for dep in target.deps:

pylib/gyp/generator/android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def ComputeOutputParts(self, spec):
697697
target,
698698
)
699699

700-
if self.type != "static_library" and self.type != "shared_library":
700+
if self.type not in {"static_library", "shared_library"}:
701701
target_prefix = spec.get("product_prefix", target_prefix)
702702
target = spec.get("product_name", target)
703703
product_ext = spec.get("product_extension")

pylib/gyp/generator/make.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ def WriteActions(
10631063
# libraries, but until everything is made cross-compile safe, also use
10641064
# target libraries.
10651065
# TODO(piman): when everything is cross-compile safe, remove lib.target
1066-
if self.flavor == "zos" or self.flavor == "aix":
1066+
if self.flavor in {"zos", "aix"}:
10671067
self.WriteLn(
10681068
"cmd_%s = LIBPATH=$(builddir)/lib.host:"
10691069
"$(builddir)/lib.target:$$LIBPATH; "
@@ -2028,7 +2028,7 @@ def WriteTarget(
20282028
installable_deps.append(
20292029
self.GetUnversionedSidedeckFromSidedeck(install_path)
20302030
)
2031-
if self.output != self.alias and self.alias != self.target:
2031+
if self.alias not in (self.output, self.target):
20322032
self.WriteMakeRule(
20332033
[self.alias],
20342034
installable_deps,

pylib/gyp/input.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,14 +1576,12 @@ def ExpandWildcardDependencies(targets, data):
15761576
continue
15771577
dependency_target_name = dependency_target_dict["target_name"]
15781578
if (
1579-
dependency_target != "*"
1580-
and dependency_target != dependency_target_name
1579+
dependency_target not in {"*", dependency_target_name}
15811580
):
15821581
continue
15831582
dependency_target_toolset = dependency_target_dict["toolset"]
15841583
if (
1585-
dependency_toolset != "*"
1586-
and dependency_toolset != dependency_target_toolset
1584+
dependency_toolset not in {"*", dependency_target_toolset}
15871585
):
15881586
continue
15891587
dependency = gyp.common.QualifiedTarget(
@@ -2541,7 +2539,7 @@ def ProcessListFiltersInDict(name, the_dict):
25412539
del_lists = []
25422540
for key, value in the_dict.items():
25432541
operation = key[-1]
2544-
if operation != "!" and operation != "/":
2542+
if operation not in {"!", "/"}:
25452543
continue
25462544

25472545
if type(value) is not list:

pylib/gyp/xcodeproj_file.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ def __init__(self, properties=None, id=None, parent=None):
971971
if "path" in self._properties and "name" not in self._properties:
972972
path = self._properties["path"]
973973
name = posixpath.basename(path)
974-
if name != "" and path != name:
974+
if name not in ("", path):
975975
self.SetProperty("name", name)
976976

977977
if "path" in self._properties and (
@@ -2546,10 +2546,10 @@ def __init__(
25462546
force_extension = suffix[1:]
25472547

25482548
if (
2549-
self._properties["productType"]
2550-
== "com.apple.product-type-bundle.unit.test"
2551-
or self._properties["productType"]
2552-
== "com.apple.product-type-bundle.ui-testing"
2549+
self._properties["productType"] in {
2550+
"com.apple.product-type-bundle.unit.test",
2551+
"com.apple.product-type-bundle.ui-testing"
2552+
}
25532553
) and force_extension is None:
25542554
force_extension = suffix[1:]
25552555

@@ -2700,8 +2700,10 @@ def AddDependency(self, other):
27002700
other._properties["productType"] == static_library_type
27012701
or (
27022702
(
2703-
other._properties["productType"] == shared_library_type
2704-
or other._properties["productType"] == framework_type
2703+
other._properties["productType"] in {
2704+
shared_library_type,
2705+
framework_type
2706+
}
27052707
)
27062708
and (
27072709
(not other.HasBuildSetting("MACH_O_TYPE"))

0 commit comments

Comments
 (0)