Skip to content

Commit

Permalink
Add return type to highlight three-valued logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hfroot committed Nov 12, 2024
1 parent d61b18e commit 1b0fcc1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions data/models/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ def total_family_autres(self):
return self.family_sum("autres")

@property
def appro_badge(self):
def appro_badge(self) -> bool | None:
total = self.value_total_ht
if total:
bio_share = (self.value_bio_ht or 0) / total
Expand Down Expand Up @@ -1689,15 +1689,15 @@ def appro_badge(self):
return False

@property
def waste_badge(self):
def waste_badge(self) -> bool | None:
if self.has_waste_diagnostic and self.waste_actions and len(self.waste_actions) > 0:
if self.has_donation_agreement or (self.canteen.daily_meal_count and self.canteen.daily_meal_count < 3000):
return True
if self.tunnel_waste:
return False

@property
def diversification_badge(self):
def diversification_badge(self) -> bool | None:
if self.vegetarian_weekly_recurrence == Diagnostic.MenuFrequency.DAILY:
return True
elif self.vegetarian_weekly_recurrence in [Diagnostic.MenuFrequency.MID, Diagnostic.MenuFrequency.HIGH]:
Expand All @@ -1708,7 +1708,7 @@ def diversification_badge(self):
return False

@property
def plastic_badge(self):
def plastic_badge(self) -> bool | None:
if (
self.cooking_plastic_substituted
and self.serving_plastic_substituted
Expand All @@ -1720,7 +1720,7 @@ def plastic_badge(self):
return False

@property
def info_badge(self):
def info_badge(self) -> bool | None:
if self.communicates_on_food_quality:
return True
if self.tunnel_info:
Expand Down

0 comments on commit 1b0fcc1

Please sign in to comment.