-
-
Notifications
You must be signed in to change notification settings - Fork 8
last_date_to_pay field can be none #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
add none as default values to some fields
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
@@ -11,8 +11,8 @@ class ResponseDescriptor(DataClassDictMixin): | |||
"""Response Descriptor""" | |||
|
|||
is_success: bool = field(metadata=field_options(alias="isSuccess")) | |||
code: Optional[str] | |||
description: Optional[str] | |||
code: Optional[str] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason for setting default values, they'll be None
by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some errors without this added line. for example: errorMessage": "Field \"response_descriptor\" of type ResponseDescriptor in ResponseWithDescriptor has invalid value {'isSuccess': True, 'code': '00'}",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When trying to parse the response:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 6, in __mashumaro_from_dict__
mashumaro.exceptions.MissingField: Field "data" of type Optional[Any] is missing in ResponseWithDescriptor instance
This means that data
field (and not code
) can be None.
Which you already added.
@SL1994-design - please fix the lint comments |
Please add newlines at the end of the files |
@SL1994-design - please do it for both files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see lint errors.
User description
add none as default values to some fields
What changes do you are proposing?
How did you test these changes?
Closing issues
PR Type
enhancement
Description
ElectricBill
dataclass to allow thelast_date_to_pay
field to beNone
by usingOptional
typing and setting a default value ofNone
.ResponseDescriptor
andResponseWithDescriptor
dataclasses to set default values ofNone
forcode
,description
, anddata
fields, enhancing the flexibility of these models.Changes walkthrough 📝
electric_bill.py
Allow `last_date_to_pay` field to be None
iec_api/models/electric_bill.py
Optional
typing tolast_date_to_pay
.last_date_to_pay
toNone
.response_descriptor.py
Set default None values for response fields
iec_api/models/response_descriptor.py
code
anddescription
toNone
.data
toNone
.