Skip to content

Commit bb2726f

Browse files
committed
Use old python 3.9 syntax for types
1 parent 68e9a53 commit bb2726f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

wger/nutrition/helpers.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
dataclass,
2121
)
2222
from decimal import Decimal
23+
from typing import Union
2324

2425
# wger
2526
from wger.nutrition.consts import (
@@ -102,14 +103,16 @@ def get_nutritional_values(self, use_metric=True):
102103

103104
@dataclass
104105
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
113116

114117
@property
115118
def energy_kilojoule(self):

0 commit comments

Comments
 (0)