Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Use old python 3.9 syntax for types

Roland Geiderbb2726fdccb1
diff --git a/wger/nutrition/helpers.py b/wger/nutrition/helpers.py
index c6b2e779b..9927542bd 100644
--- a/wger/nutrition/helpers.py
+++ b/wger/nutrition/helpers.py
@@ -20,6 +20,7 @@ from dataclasses import (
dataclass,
)
from decimal import Decimal
+from typing import Union
# wger
from wger.nutrition.consts import (
@@ -102,14 +103,16 @@ class BaseMealItem:
@dataclass
class NutritionalValues:
- energy: Decimal | int | float = 0
- protein: Decimal | int | float = 0
- carbohydrates: Decimal | int | float = 0
- carbohydrates_sugar: Decimal | int | float | None = None
- fat: Decimal | int | float = 0
- fat_saturated: Decimal | int | float | None = None
- fibres: Decimal | int | float | None = None
- sodium: Decimal | int | float | None = None
+ # TODO: replace the Union with | when we drop support for python 3.9
+
+ energy: Union[Decimal, int, float] = 0
+ protein: Union[Decimal, int, float] = 0
+ carbohydrates: Union[Decimal, int, float] = 0
+ carbohydrates_sugar: Union[Decimal, int, float, None] = None
+ fat: Union[Decimal, int, float] = 0
+ fat_saturated: Union[Decimal, int, float, None] = None
+ fibres: Union[Decimal, int, float, None] = None
+ sodium: Union[Decimal, int, float, None] = None
@property
def energy_kilojoule(self):