|
20 | 20 | dataclass,
|
21 | 21 | )
|
22 | 22 | from decimal import Decimal
|
| 23 | +from typing import Union |
23 | 24 |
|
24 | 25 | # wger
|
25 | 26 | from wger.nutrition.consts import (
|
@@ -102,14 +103,16 @@ def get_nutritional_values(self, use_metric=True):
|
102 | 103 |
|
103 | 104 | @dataclass
|
104 | 105 | class NutritionalValues:
|
105 |
| - energy: Decimal | int | float = 0 |
106 |
| - protein: Decimal | int | float = 0 |
107 |
| - carbohydrates: Decimal | int | float = 0 |
108 |
| - carbohydrates_sugar: Decimal | int | float | None = None |
109 |
| - fat: Decimal | int | float = 0 |
110 |
| - fat_saturated: Decimal | int | float | None = None |
111 |
| - fibres: Decimal | int | float | None = None |
112 |
| - sodium: Decimal | int | float | None = None |
| 106 | + # TODO: replace the Union with | when we drop support for python 3.9 |
| 107 | + |
| 108 | + energy: Union[Decimal, int, float] = 0 |
| 109 | + protein: Union[Decimal, int, float] = 0 |
| 110 | + carbohydrates: Union[Decimal, int, float] = 0 |
| 111 | + carbohydrates_sugar: Union[Decimal, int, float, None] = None |
| 112 | + fat: Union[Decimal, int, float] = 0 |
| 113 | + fat_saturated: Union[Decimal, int, float, None] = None |
| 114 | + fibres: Union[Decimal, int, float, None] = None |
| 115 | + sodium: Union[Decimal, int, float, None] = None |
113 | 116 |
|
114 | 117 | @property
|
115 | 118 | def energy_kilojoule(self):
|
|
0 commit comments