From d649c9166b12ca5d64a1c1074469ebb07b951109 Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 5 Mar 2024 18:17:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(model):=20=E4=BF=AE=E5=A4=8D=20ProductDetai?= =?UTF-8?q?lsResponse=20=E4=B8=AD=20ProductBarcode=20amount=20=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=B8=BA=20None=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pygrocy/data_models/product.py | 6 +++--- pygrocy/grocy_api_client.py | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pygrocy/data_models/product.py b/pygrocy/data_models/product.py index 068ef11..b7c6461 100644 --- a/pygrocy/data_models/product.py +++ b/pygrocy/data_models/product.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import List +from typing import List, Union from pygrocy.base import DataModel from pygrocy.grocy_api_client import ( @@ -19,14 +19,14 @@ class ProductBarcode(DataModel): def __init__(self, data: ProductBarcodeData): self._barcode = data.barcode - self._amount = float(data.amount) + self._amount = float(data.amount) if data.amount else None @property def barcode(self) -> str: return self._barcode @property - def amount(self) -> float: + def amount(self) -> Union[float, None]: return self._amount diff --git a/pygrocy/grocy_api_client.py b/pygrocy/grocy_api_client.py index e920e30..2bb7098 100644 --- a/pygrocy/grocy_api_client.py +++ b/pygrocy/grocy_api_client.py @@ -161,7 +161,7 @@ class CurrentVolatilStockResponse(BaseModel): class ProductBarcodeData(BaseModel): barcode: str - amount: float + amount: Optional[float] = None class ProductDetailsResponse(BaseModel): diff --git a/setup.py b/setup.py index cb4e479..53dcab1 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pygrocy", - version="2.0.1", + version="2.0.2", author="Sebastian Rutofski", author_email="kontakt@sebastian-rutofski.de", description="",