-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Optional/Nullable support to Python Cluster Objects #11515
Merged
mrjerryjohns
merged 7 commits into
project-chip:master
from
mrjerryjohns:python/nullable-optional
Nov 15, 2021
Merged
Optional/Nullable support to Python Cluster Objects #11515
mrjerryjohns
merged 7 commits into
project-chip:master
from
mrjerryjohns:python/nullable-optional
Nov 15, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f323da3
to
03e0579
Compare
This amongst other things, adds support for optional and nullable types to the Python cluster objects. It does so by leveraging typing.Union and typing.Optional to do so. To represent nulls, a new Nullable type has been created to encapsulate that. Consequently, 'None' indicates an optional field that is not present. 'NullValue' indicates a null-value. Consequently, the following representations map to the various combinations: typing.Union[base-type, Types.Nullable] => a nullable base-type. typing.Optional[base-type] => an optional base-type typing.Union[base-type, Types.Nullable, None] => an optional, nullable, base-type. In addition, the generation helpers for Python have been cleaned up to better align with how it's done for the other languages. Finally, a unit-test for the generated objects has been added which was crucial to fix some critical bugs in the implementation. Tests: - Validated using test_generated_clusterobjects.py. - Validated by sending commands to the test cluster to a device.
03e0579
to
f29bb8b
Compare
PR #11515: Size comparison from 6201b8e to f29bb8b Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
erjiaqing
reviewed
Nov 8, 2021
woody-apple
approved these changes
Nov 9, 2021
andy31415
approved these changes
Nov 12, 2021
PR #11515: Size comparison from ea10a5d to 2f52efc Increases above 0.2%:
Increases (34 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Decreases (3 builds for mbed, nrfconnect, p6)
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
72c1899
to
93d06c9
Compare
PR #11515: Size comparison from 507ba15 to 93d06c9 Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
erjiaqing
reviewed
Nov 15, 2021
src/controller/python/test/unit_tests/test_generated_clusterobjects.py
Outdated
Show resolved
Hide resolved
fast track: open for a long time, had sufficient time for feedback (and several comments provided & resolved). PR created and reviwed by domain owner. |
PSONALl
pushed a commit
to PSONALl/connectedhomeip
that referenced
this pull request
Dec 3, 2021
* Optional/Nullable support to Python Cluster Objects This amongst other things, adds support for optional and nullable types to the Python cluster objects. It does so by leveraging typing.Union and typing.Optional to do so. To represent nulls, a new Nullable type has been created to encapsulate that. Consequently, 'None' indicates an optional field that is not present. 'NullValue' indicates a null-value. Consequently, the following representations map to the various combinations: typing.Union[base-type, Types.Nullable] => a nullable base-type. typing.Optional[base-type] => an optional base-type typing.Union[base-type, Types.Nullable, None] => an optional, nullable, base-type. In addition, the generation helpers for Python have been cleaned up to better align with how it's done for the other languages. Finally, a unit-test for the generated objects has been added which was crucial to fix some critical bugs in the implementation. Tests: - Validated using test_generated_clusterobjects.py. - Validated by sending commands to the test cluster to a device. * Review feedback * Fixes the equality comparison in Python for Nones * Re-gen cluster objects * Adding debug mode to the newly added unit test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This amongst other things, adds support for optional and nullable types to the Python cluster objects. It does so by leveraging
typing.Union
andtyping.Optional
to do so. To represent nulls, a newNullable
type hasbeen created to encapsulate that.
Consequently,
None
indicates an optional field that is not present.NullValue
indicates a null-value.Consequently, the following representations map to the various combinations:
typing.Union[base-type, Types.Nullable]
=> a nullable base-type.typing.Optional[base-type]
=> an optional base-typetyping.Union[base-type, Types.Nullable, None]
=> an optional, nullable,base-type.
In addition, the generation helpers for Python have been cleaned up to better align with how it's done for the other languages.
Finally, a unit-test for the generated objects has been added which was crucial to fix some critical bugs in the implementation.
Tests: