minos-python icon indicating copy to clipboard operation
minos-python copied to clipboard

`minos.common.DeclarativeModel` class does not support default values

Open garciparedes opened this issue 3 years ago • 3 comments

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.

garciparedes avatar Jan 26 '22 10:01 garciparedes

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!

garciparedes avatar Jan 26 '22 10:01 garciparedes

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.

stale[bot] avatar Apr 27 '22 00:04 stale[bot]

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.

stale[bot] avatar Aug 09 '22 08:08 stale[bot]