HugoPelletier opened a new pull request #11508:
URL: https://github.com/apache/pulsar/pull/11508
Fixes #11473
### Motivation
By default, classes that inherit from Fields have a `required` key argument
which is False.
If an attribute is not declared with a value, an exception is raised.
```python
Invalid type '<class' NoneType '>' for field 'name'. Expected a string
```
### Modifications
The modifications made affect 2 classes: Field and String. In both cases,
the `validate_type` method has been modified to take into account arguments
inherited from the Field class, including` required` and `default`.
Validation looks to see if the field is required. If it is not required
(`required=False`) and the value does not exist, the default value is returned.
This modification removes the error and allows to integrate the different
types of fields based on the definition of the key arguments of the Field class
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
This change added tests and can be verified as follows:
- *Added unit teststo validate that all types of fields are returning the
expected default value and are not raising an error anymore*
### Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API: no
- The schema: yes
- The default values of configurations: no
- The wire protocol: no
- The rest endpoints: no
- The admin cli options: no
- Anything that affects deployment: no
### Documentation
#### For commiter
No documentation update is required.
The implementation of any fields is not include in the documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]