mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-23 15:31:37 -04:00
Fix TypeError in clean_nutrition function (#1043)
* Fix Null error * Better fix * Black fixes * extend-ignore should be used for adding ignore
This commit is contained in:
parent
73c537ed36
commit
6c549ff993
2
.flake8
2
.flake8
@ -1,5 +1,5 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
ignore = [
|
extend-ignore = [
|
||||||
E501 # Line Length - See Black Config in pyproject.toml
|
E501 # Line Length - See Black Config in pyproject.toml
|
||||||
E402 # Import Not at Top of File
|
E402 # Import Not at Top of File
|
||||||
]
|
]
|
||||||
|
@ -93,7 +93,12 @@ def clean_nutrition(nutrition: Optional[dict]) -> dict[str, str]:
|
|||||||
|
|
||||||
output_nutrition = {key: val.replace(",", ".") for key, val in output_nutrition.items()}
|
output_nutrition = {key: val.replace(",", ".") for key, val in output_nutrition.items()}
|
||||||
|
|
||||||
if "sodiumContent" in nutrition and "m" not in nutrition["sodiumContent"] and "g" in nutrition["sodiumContent"]:
|
if (
|
||||||
|
"sodiumContent" in nutrition
|
||||||
|
and type(nutrition["sodiumContent"]) == str
|
||||||
|
and "m" not in nutrition["sodiumContent"]
|
||||||
|
and "g" in nutrition["sodiumContent"]
|
||||||
|
):
|
||||||
# Sodium is in grams. Parse its value, multiple by 1k and return to string.
|
# Sodium is in grams. Parse its value, multiple by 1k and return to string.
|
||||||
try:
|
try:
|
||||||
output_nutrition["sodiumContent"] = str(float(output_nutrition["sodiumContent"]) * 1000)
|
output_nutrition["sodiumContent"] = str(float(output_nutrition["sodiumContent"]) * 1000)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user