Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@carlolars
Copy link
Contributor

Just a simple change to the format when logging bytes, example log output:

old: Received ZCL frame: b'\x185\n\x0b\x05)\xb8\x02'
new: Received ZCL frame: '18 35 0a 0b 05 29 b8 02'

Copilot AI review requested due to automatic review settings September 14, 2025 17:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the readability of binary data in debug logs by formatting bytes as hexadecimal strings with spaces instead of Python's default bytes representation.

  • Replaces raw bytes representation with space-separated hex format in debug logs
  • Updates four debug log statements in the ZCL frame deserializer
  • Maintains the same logging level and information while improving readability

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 304 to 311
self.debug("Unknown cluster command %s %r", hdr.command_id, data.hex(" "))
return hdr, data

command = commands[hdr.command_id]
else:
# General command
if hdr.command_id not in foundation.GENERAL_COMMANDS:
self.debug("Unknown foundation command %s %s", hdr.command_id, data)
self.debug("Unknown foundation command %s %r", hdr.command_id, data.hex(" "))
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format string uses %r for hex data but %s for command_id. Consider using %s for both since data.hex(" ") returns a string, making the %r unnecessary and potentially confusing.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately used %r to get the repr of the string, the difference between %s and %r is that r encloses the string in ' ('str'),

%r: Received ZCL frame: '18 35 0a 0b 05 29 b8 02'
%s: Received ZCL frame: 18 35 0a 0b 05 29 b8 02

# General command
if hdr.command_id not in foundation.GENERAL_COMMANDS:
self.debug("Unknown foundation command %s %s", hdr.command_id, data)
self.debug("Unknown foundation command %s %r", hdr.command_id, data.hex(" "))
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format string uses %r for hex data but %s for command_id. Consider using %s for both since data.hex(" ") returns a string, making the %r unnecessary and potentially confusing.

Suggested change
self.debug("Unknown foundation command %s %r", hdr.command_id, data.hex(" "))
self.debug("Unknown foundation command %s %s", hdr.command_id, data.hex(" "))

Copilot uses AI. Check for mistakes.

if data:
self.debug("Data remains after deserializing ZCL frame: %r", data)
self.debug("Data remains after deserializing ZCL frame: %r", data.hex(" "))
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format string uses %r for hex data. Consider using %s instead since data.hex(" ") returns a string, making the %r unnecessary and potentially confusing.

Suggested change
self.debug("Data remains after deserializing ZCL frame: %r", data.hex(" "))
self.debug("Data remains after deserializing ZCL frame: %s", data.hex(" "))

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Sep 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.31%. Comparing base (6ab924a) to head (6ceb71b).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1669   +/-   ##
=======================================
  Coverage   99.31%   99.31%           
=======================================
  Files          63       63           
  Lines       12184    12184           
=======================================
  Hits        12100    12100           
  Misses         84       84           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@puddly puddly merged commit a78dd9f into zigpy:dev Oct 27, 2025
23 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants