Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
fix(model): 修复 ProductDetailsResponse 中 ProductBarcode amount 不能为 Non…
Browse files Browse the repository at this point in the history
…e 的问题
  • Loading branch information
looching committed Mar 5, 2024
1 parent f352bac commit d649c91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pygrocy/data_models/product.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion pygrocy/grocy_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class CurrentVolatilStockResponse(BaseModel):

class ProductBarcodeData(BaseModel):
barcode: str
amount: float
amount: Optional[float] = None


class ProductDetailsResponse(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pygrocy",
version="2.0.1",
version="2.0.2",
author="Sebastian Rutofski",
author_email="[email protected]",
description="",
Expand Down

0 comments on commit d649c91

Please sign in to comment.