Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix PLR1714 lint errors #202

Merged
merged 6 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pylib/gyp/generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -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; "
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 9 additions & 7 deletions pylib/gyp/xcodeproj_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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:]

Expand Down Expand Up @@ -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"))
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ select = [
# "TRY", # tryceratops
]
ignore = [
"E721",
"PLC1901",
"PLR0402",
"PLR2004",
"PLR5501",
"PLW0603",
"PLW2901",
"PYI024",
"RUF005",
"RUF012",
"UP031",
Expand Down