Skip to content

Add __repr__ to the sync serial port - #156

Merged
puddly merged 2 commits into
puddly:devfrom
Happyfield7:add-serial-repr
Nov 20, 2026
Merged

puddly merged 2 commits into
puddly:devfrom
Happyfield7:add-serial-repr

Conversation

@Happyfield7

Copy link
Copy Markdown
Contributor

Problem

AsyncSerial has a readable repr(), but the sync port shows only <serialx.platforms.serial_linux.LinuxSerial object at 0x...>, so logs and debugger output do not say which port it is or whether it is open.

Change

BaseSerial.__repr__ returns <LinuxSerial path='/dev/ttyUSB0' baudrate=115200 open=True>. The path goes through redact_uri(), like AsyncSerial.__repr__, so ESPHome keys are not shown. PyodideSerial.is_open now returns False instead of raising, because the transport only uses that class to hold settings and repr() reads is_open.

Testing

Unit tests cover an unopened port, secret redaction and the Pyodide class; a pair test checks open= across open and close on every backend. Full suite passes on macOS and Debian sid.

@puddly
puddly enabled auto-merge (squash) November 20, 2026 17:46
@puddly
puddly merged commit 2c500d7 into puddly:dev Nov 20, 2026
31 checks passed
@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.38%. Comparing base (36a099e) to head (643db5e).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #156      +/-   ##
==========================================
+ Coverage   94.36%   94.38%   +0.02%     
==========================================
  Files          25       25              
  Lines        4433     4437       +4     
==========================================
+ Hits         4183     4188       +5     
+ Misses        250      249       -1     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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