diff --git a/ci/rust_ci_helper.py b/ci/rust_ci_helper.py index e1a0aa2a..9c73bd29 100755 --- a/ci/rust_ci_helper.py +++ b/ci/rust_ci_helper.py @@ -53,10 +53,8 @@ def predicate(package): def find_flavored_crates(*, workspace_crates): def predicate(package): - tmp = package.get("metadata") or {} - tmp = tmp.get("orb") or {} - flavors = tmp.get("flavors") or {} - if flavors == {}: + flavors = package.get("metadata", {}).get("orb", {}).get("flavors", {}) + if not flavors: return False if not isinstance(flavors, list): raise ValueError("`flavors` must be a list") @@ -75,12 +73,12 @@ def predicate(package): def find_unsupported_platform_crates(*, host_platform, workspace_crates): def predicate(package): - tmp = package.get("metadata") or {} - tmp = tmp.get("orb") or {} - tmp = tmp.get("unsupported_targets") or {} - if tmp == {}: + unsupported_targets = ( + package.get("metadata", {}).get("orb", {}).get("unsupported_targets", {}) + ) + if not unsupported_targets: return False - return host_platform in tmp + return host_platform in unsupported_targets return {n: p for n, p in workspace_crates.items() if predicate(p)} @@ -165,9 +163,7 @@ def get_binaries(*, crate): def get_crate_flavors(*, crate): """extracts a dictionary of flavor_name => list[feature] for a given crate's metadata""" - flavors = crate.get("metadata") or {} - flavors = flavors.get("orb") or {} - flavors = flavors.get("flavors") or {} + flavors = crate.get("metadata", {}).get("orb", {}).get("flavors", {}) return {f["name"]: f["features"] for f in flavors}