minos-python
minos-python copied to clipboard
`minos.common.DeclarativeModel` class does not support default values
Issue by vladyslav-fenchak
Friday Aug 13, 2021 at 07:57 GMT
Originally opened as https://github.com/Clariteia/minos_microservice_common/issues/530
Example:
from minos.common import (
DeclarativeModel,
)
class Inventory(DeclarativeModel):
amount: int = 0
reserved: int = 0
sold: int = 0
Current error message:
self = <minos.common.model.serializers.avro_data_decoder.AvroDataDecoder object at 0x103a531f0>
type_field = <class 'int'>
data = <class 'minos.common.model.types.data_types.MissingSentinel'>
def _cast_single_value(self, type_field: Type, data: Any) -> Any:
if type_field is NoneType:
return self._cast_none_value(type_field, data)
if data is None:
raise MinosReqAttributeException(f"{self._name!r} field is '{None!r}'.")
if data is MissingSentinel:
> raise MinosReqAttributeException(f"{self._name!r} field is missing.")
> minos.common.exceptions.MinosReqAttributeException: 'reserved' field is missing.
Comment by garciparedes
Friday Sep 24, 2021 at 10:10 GMT
I agree with you @vladyslav-fenchak, this is an interesting feature we should implement in the future!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.