-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fix discovery display when values are unexpectedly empty #1082
Conversation
Fixes ``` File "/usr/local/lib/python3.11/dist-packages/aioesphomeapi/discover.py", line 47, in async_service_update print(FORMAT.format(state, short_name, address, mac, version, platform, board)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unsupported format string passed to NoneType.__format__ ```
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1082 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 2731 2731
=========================================
Hits 2731 2731 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #1082 will not alter performanceComparing Summary
|
WalkthroughThe changes update the behavior of byte decoding in the "aioesphomeapi/discover.py" module. A new constant Changes
Sequence Diagram(s)sequenceDiagram
participant Service as async_service_update
participant Decoder as decode_bytes_or_unknown
Service->>Decoder: call decode_bytes_or_unknown(data)
alt data is None
Decoder-->>Service: returns "unknown"
else data is provided
Decoder-->>Service: returns decoded string
end
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
aioesphomeapi/discover.py (1)
17-23
: Consider enhancing the docstring.The function changes look good and align well with the PR objective. The return type is now more predictable, always returning a string.
Consider expanding the docstring to be more descriptive:
- """Decode bytes or return unknown.""" + """Decode bytes or return a default string value. + + Args: + data: The input data to decode, can be str, bytes, or None + + Returns: + str: The decoded string or "unknown" if the input is None + """
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
aioesphomeapi/discover.py
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams
**
: - Do not generate or add any sequence diagrams
aioesphomeapi/discover.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: py 3.12 on windows-latest (skip_cython)
🔇 Additional comments (2)
aioesphomeapi/discover.py (2)
14-14
: LGTM! Good use of a constant for consistent handling of unknown values.The constant follows Python naming conventions and provides a clear, reusable value for handling missing data.
38-41
: LGTM! Consistent handling of potentially missing properties.The changes effectively prevent TypeError when formatting empty values, which directly addresses the PR objective. The implementation is consistent across all property accesses.
Fixes
aioesphomeapi-discover
failing on empty values.reported at esphome/issues#6311 (comment)