From 23e36e9ea6dec181bf450b75417490ac5fefabda Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:58:35 -0400 Subject: [PATCH] chore(style): Use set for set inclusion condition --- contracting_process/field_level/definitions.py | 4 ++-- .../resource_level/consistent/contracts_value.py | 4 ++-- .../resource_level/consistent/tender_value.py | 2 +- manage.py | 2 +- pelican/util/getter.py | 6 +++--- workers/check/dataset.py | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contracting_process/field_level/definitions.py b/contracting_process/field_level/definitions.py index 5ed43a2c..3f67ba52 100644 --- a/contracting_process/field_level/definitions.py +++ b/contracting_process/field_level/definitions.py @@ -52,7 +52,7 @@ def _definitions(properties, path=None, refs=None): elif refs[-1] == "ContactPoint": if key == "email": checks.append((email.calculate, email.name)) - elif key in ("faxNumber", "telephone"): + elif key in {"faxNumber", "telephone"}: checks.append((telephone.calculate, telephone.name)) elif refs[-1] == "Document": if key == "description": @@ -82,7 +82,7 @@ def _definitions(properties, path=None, refs=None): if key == "numberOfTenderers": checks.append((number.calculate, number.name)) elif refs[-1] == "Value": # noqa: SIM102 # consistency - if key == "amount" and new_path[-3] in ("transactions", "unit"): + if key == "amount" and new_path[-3] in {"transactions", "unit"}: checks.append((number.calculate, number.name)) yield dot_path, checks diff --git a/contracting_process/resource_level/consistent/contracts_value.py b/contracting_process/resource_level/consistent/contracts_value.py index e5183513..3e129037 100644 --- a/contracting_process/resource_level/consistent/contracts_value.py +++ b/contracting_process/resource_level/consistent/contracts_value.py @@ -71,7 +71,7 @@ def calculate(item): award_amount = get_amount(no_conversion, unconverted_amount, currency, date) # (2,5) Amount is zero or unconvertable. - if award_amount in (0, None): + if award_amount in {0, None}: continue contracts_amount_sum = 0 @@ -85,7 +85,7 @@ def calculate(item): contract_amount = get_amount(no_conversion, unconverted_amount, currency, date) # (2,5) Amount is zero or unconvertable. - if contract_amount in (0, None): + if contract_amount in {0, None}: break # (4) Different signs. diff --git a/contracting_process/resource_level/consistent/tender_value.py b/contracting_process/resource_level/consistent/tender_value.py index 3a7436da..1f3fb25c 100644 --- a/contracting_process/resource_level/consistent/tender_value.py +++ b/contracting_process/resource_level/consistent/tender_value.py @@ -38,7 +38,7 @@ def calculate(item): planning_amount = convert(planning_amount, planning_currency, "USD", date) tender_amount = convert(tender_amount, tender_currency, "USD", date) - if planning_amount in (0, None) or tender_amount in (0, None): + if planning_amount in {0, None} or tender_amount in {0, None}: result["meta"] = {"reason": "an amount is zero or unconvertable"} return result diff --git a/manage.py b/manage.py index ee320518..8b0e799d 100755 --- a/manage.py +++ b/manage.py @@ -46,7 +46,7 @@ def remove(dataset_id, include_filtered, force): {"dataset_id": dataset_id}, ) row = cursor.fetchone() - if not row or row[0] not in (Phase.CHECKED, Phase.DELETED) or row[1] != State.OK: + if not row or row[0] not in {Phase.CHECKED, Phase.DELETED} or row[1] != State.OK: if force: click.secho( f"Forcefully removing dataset {dataset_id} (phase={row[0]}, state={row[1]}). (Its phase should be " diff --git a/pelican/util/getter.py b/pelican/util/getter.py index abacf38f..d3f9f6be 100644 --- a/pelican/util/getter.py +++ b/pelican/util/getter.py @@ -93,7 +93,7 @@ def deep_get(value: Any, path: str, force: type[Any] | None = None) -> Any: for part in path.split("."): if type(value) is dict and part in value: value = value[part] - elif force in (dict, list, str): + elif force in {dict, list, str}: return force() else: return None @@ -103,9 +103,9 @@ def deep_get(value: Any, path: str, force: type[Any] | None = None) -> Any: return parse_date(value) if force is datetime.datetime: return parse_datetime(value) - if force in (dict, list): + if force in {dict, list}: value = force() - elif force in (float, int, str): + elif force in {float, int, str}: try: value = force(value) except (ValueError, TypeError): diff --git a/workers/check/dataset.py b/workers/check/dataset.py index 77538510..3153281b 100644 --- a/workers/check/dataset.py +++ b/workers/check/dataset.py @@ -44,7 +44,7 @@ def callback(client_state, channel, method, properties, input_message): logger.info("Dataset %s: DATASET phase already in-progress", dataset_id) ack(client_state, channel, delivery_tag) return - if dataset["phase"] in (Phase.DATASET, Phase.TIME_VARIANCE, Phase.CHECKED, Phase.DELETED): + if dataset["phase"] in {Phase.DATASET, Phase.TIME_VARIANCE, Phase.CHECKED, Phase.DELETED}: logger.info("Dataset %s: DATASET phase already complete", dataset_id) ack(client_state, channel, delivery_tag) return