Skip to content

Commit

Permalink
chore(style): Use set for set inclusion condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Sep 27, 2024
1 parent 0ef17f8 commit 23e36e9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions contracting_process/field_level/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
6 changes: 3 additions & 3 deletions pelican/util/getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion workers/check/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23e36e9

Please sign in to comment.