feat: ensure ServiceInfo.properties always returns bytes#1333
Merged
Conversation
Clean up the typing on `ServiceInfo.properties` to always return bytes. The typing on properties was very confusing because it could have a mix of bytes and str types, but only bytes would ever come back from the backend and cache. The only way str could happen is if someone manually passed it in. We now ensure all passed in data is converted to bytes
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1333 +/- ##
=======================================
Coverage 99.77% 99.77%
=======================================
Files 30 30
Lines 3143 3155 +12
Branches 524 526 +2
=======================================
+ Hits 3136 3148 +12
Misses 5 5
Partials 2 2 ☔ View full report in Codecov by Sentry. |
openstack-mirroring
pushed a commit
to openstack/openstack
that referenced
this pull request
Jan 5, 2024
* Update ironic-lib from branch 'master'
to 523407eebf22b68a3b1a3926666e8bb24fedf871
- Merge "Compatibility with zeroconf 0.129.0"
- Compatibility with zeroconf 0.129.0
From Zeroconf CHANGELOG.md:
v0.129.0 (2023-12-13)
Feature
* Add decoded_properties method to ServiceInfo
python-zeroconf/python-zeroconf#1332
python-zeroconf/python-zeroconf@9b595a1
* Ensure ServiceInfo.properties always returns bytes
python-zeroconf/python-zeroconf#1333
python-zeroconf/python-zeroconf@d29553a
Technically breaking change
* `ServiceInfo.properties` always returns a dictionary with type
`dict[bytes, bytes | None]` instead of a mix `str` and `bytes`. It was
only possible to get a mixed dictionary if it was manually passed in
when `ServiceInfo` was constructed.
Co-Authored-By: Dmitry Tantsur <dtantsur@protonmail.com>
Change-Id: I7f1a0c3329e5f29ec3e274558e3681142cc2ef78
openstack-mirroring
pushed a commit
to openstack/ironic-lib
that referenced
this pull request
Jan 5, 2024
From Zeroconf CHANGELOG.md: v0.129.0 (2023-12-13) Feature * Add decoded_properties method to ServiceInfo python-zeroconf/python-zeroconf#1332 python-zeroconf/python-zeroconf@9b595a1 * Ensure ServiceInfo.properties always returns bytes python-zeroconf/python-zeroconf#1333 python-zeroconf/python-zeroconf@d29553a Technically breaking change * `ServiceInfo.properties` always returns a dictionary with type `dict[bytes, bytes | None]` instead of a mix `str` and `bytes`. It was only possible to get a mixed dictionary if it was manually passed in when `ServiceInfo` was constructed. Co-Authored-By: Dmitry Tantsur <dtantsur@protonmail.com> Change-Id: I7f1a0c3329e5f29ec3e274558e3681142cc2ef78
This file contains hidden or 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
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.
Clean up
ServiceInfo.propertiesto always returnbytes.This is a technically breaking change. Its seems unlikely anyone is using it this way, but there is always someone. The type for the incoming
Dictis missing which makes the interface unclear, and we ended up with a messy mix internally. This PR aims to correct that. Adding the type would likely cause more pain so its not done in this PRWe continue to allow passing in properties as a mix of bytes and str with the type
Union[bytes, Dict[Union[str, bytes], Optional[Union[str, bytes]]]], but we will now convert anystrtobytesThe typing on properties was very confusing because it could have a mix of bytes and str types, but only bytes would ever come back from the backend and cache. The only way str could happen is if someone manually passed it in. We now ensure all passed in data is converted to bytes which allows downstream to remove a significant amount of code that tried to deal with the mismatched str/bytes values.