Skip to content

Commit 75369be

Browse files
lint fix
1 parent 26c9e75 commit 75369be

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

src/eligibility_signposting_api/services/calculators/eligibility_calculator.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
IterationResult,
2323
Status,
2424
)
25-
from eligibility_signposting_api.services.calculators.rule_calculator import RuleCalculator
25+
from eligibility_signposting_api.services.calculators.rule_calculator import (
26+
RuleCalculator,
27+
)
2628

2729
Row = Collection[Mapping[str, Any]]
2830

@@ -51,25 +53,28 @@ def campaigns_grouped_by_condition_name(
5153
) -> Iterator[tuple[eligibility.ConditionName, list[rules.CampaignConfig]]]:
5254
"""Generator function to iterate over campaign groups by condition name."""
5355
for condition_name, campaign_group in groupby(
54-
sorted(self.active_campaigns, key=attrgetter("target")), key=attrgetter("target")
56+
sorted(self.active_campaigns, key=attrgetter("target")),
57+
key=attrgetter("target"),
5558
):
5659
yield condition_name, list(campaign_group)
5760

5861
@property
5962
def person_cohorts(self) -> set[str]:
6063
cohorts_row: Mapping[str, dict[str, dict[str, dict[str, Any]]]] = next(
61-
(row for row in self.person_data if row.get("ATTRIBUTE_TYPE") == "COHORTS"), {}
64+
(row for row in self.person_data if row.get("ATTRIBUTE_TYPE") == "COHORTS"),
65+
{},
6266
)
6367
return set(cohorts_row.get("COHORT_MAP", {}).get("cohorts", {}).get("M", {}).keys())
6468

6569
@staticmethod
66-
def get_the_best_cohort_memberships(cohort_results: dict[str, CohortResult]) -> tuple[Status, list[CohortResult]]:
70+
def get_the_best_cohort_memberships(
71+
cohort_results: dict[str, CohortResult],
72+
) -> tuple[Status, list[CohortResult]]:
6773
"""
6874
1. Get all the cohorts with the best status
6975
2. Case 1: Ignore magic cohort if other cohorts have better status
70-
Case 2: If no cohorts have the better status than magic cohort,
71-
then response excludes cohort memberships but will have actions/suitability rules
72-
also, excludes the cohorts with no positive or negative description
76+
Case 2: If no cohorts have the better status than magic cohort, then response excludes cohort memberships but
77+
will have actions/suitability rules also excludes the cohorts with no positive or negative description
7378
"""
7479
if not cohort_results:
7580
return eligibility.Status.not_eligible, []
@@ -78,7 +83,12 @@ def get_the_best_cohort_memberships(cohort_results: dict[str, CohortResult]) ->
7883
if all(cc.cohort_code and str(cc.cohort_code.upper()) == MAGIC_COHORT_LABEL.upper() for cc in best_cohorts):
7984
# Update the magic cohort to have no cohort membership information
8085
best_cohorts = [
81-
CohortResult(cohort_code="", status=best_status, reasons=best_cohorts[0].reasons, description="")
86+
CohortResult(
87+
cohort_code="",
88+
status=best_status,
89+
reasons=best_cohorts[0].reasons,
90+
description="",
91+
)
8292
]
8393
else:
8494
best_cohorts = [
@@ -135,7 +145,7 @@ def evaluate_eligibility(self) -> eligibility.EligibilityStatus:
135145
# Not base eligible
136146
elif cohort.cohort_label is not None:
137147
cohort_results[cohort.cohort_label] = CohortResult(
138-
cohort.cohort_group if cohort.cohort_group else cohort.cohort_label,
148+
(cohort.cohort_group if cohort.cohort_group else cohort.cohort_label),
139149
Status.not_eligible,
140150
[],
141151
str(cohort.negative_description),
@@ -158,7 +168,9 @@ def evaluate_eligibility(self) -> eligibility.EligibilityStatus:
158168
return eligibility.EligibilityStatus(conditions=final_result)
159169

160170
@staticmethod
161-
def build_condition_results(condition_results: dict[ConditionName, IterationResult]) -> list[Condition]:
171+
def build_condition_results(
172+
condition_results: dict[ConditionName, IterationResult],
173+
) -> list[Condition]:
162174
conditions: list[Condition] = []
163175
# iterate over conditions
164176
for condition_name, active_iteration_result in condition_results.items():
@@ -200,7 +212,7 @@ def is_eligible_by_filter_rules(
200212
if status.is_exclusion:
201213
if cohort.cohort_label is not None:
202214
cohort_results[str(cohort.cohort_label)] = CohortResult(
203-
cohort.cohort_group if cohort.cohort_group else cohort.cohort_label,
215+
(cohort.cohort_group if cohort.cohort_group else cohort.cohort_label),
204216
Status.not_eligible,
205217
[],
206218
str(cohort.negative_description),

0 commit comments

Comments
 (0)