Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #79 +/- ##
==========================================
+ Coverage 90.71% 91.08% +0.37%
==========================================
Files 22 22
Lines 3372 3748 +376
==========================================
+ Hits 3059 3414 +355
- Misses 313 334 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new simplified asyncio-facing API (serialx.async_serial_for_url) that returns an AsyncSerial object with a sync-like method surface, and updates tests + documentation to prefer this higher-level async interface over the existing (StreamReader, StreamWriter) pattern.
Changes:
- Added
AsyncSerialand theasync_serial_for_url()factory, and exported them fromserialx. - Refactored tests to use
AsyncSerial(including cross-loop ESPHome scenarios) and simplified test helpers. - Updated/expanded docs to steer users toward the simplified async API while keeping the streams/transport APIs documented.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
serialx/async_serial.py |
Introduces AsyncSerial and async_serial_for_url(); implements read/write/flush and modem-pin helpers. |
serialx/__init__.py |
Exports AsyncSerial and async_serial_for_url from the package root. |
serialx/common.py |
Adds ConnectKwargs TypedDict and updates BaseSerialTransport.connect/_connect typing to use Unpack. |
serialx/descriptor_transport.py |
Adjusts _connect signature to accept path + ConnectKwargs. |
serialx/platforms/serial_esphome.py |
Updates transport _connect signature and forwards path explicitly. |
serialx/platforms/serial_rfc2217/__init__.py |
Updates transport _connect signature and forwards path explicitly into RFC2217Serial. |
serialx/platforms/serial_win32.py |
Updates transport _connect signature and typing around forwarded connect kwargs. |
tests/common.py |
Replaces stream reader/writer helpers with async_create_serial_pair() yielding AsyncSerial objects. |
tests/test_async_transports.py |
Migrates tests to AsyncSerial and the new serial-pair helper. |
tests/test_serial_esphome.py |
Migrates ESPHome tests from streams API to AsyncSerial, including cross-loop coverage. |
README.md |
Documents the simplified async API and keeps the streams/transport alternatives. |
docs/usage.md |
Adds a “simple async API” section and positions streams/transport as alternatives. |
docs/quickstart.md |
Updates quickstart async section to use async_serial_for_url. |
docs/index.md |
Adds a new how-to page entry for async serial. |
docs/how-to/async-serial.md |
New how-to describing patterns and tradeoffs for the simplified async API. |
docs/how-to/pyserial-migration.md |
Adds guidance for migrating sync serial_for_url code to the new async API. |
docs/api/platforms/posix.md |
Removes an extra autofunction block from the POSIX docs page. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
86885e5 to
0214792
Compare
This PR introduces
serialx.async_serial_for_url, a simple async API:This makes migration of existing sync code straightforward, as often times even simple scripts graduate to needing background tasks, timeouts, and so on. I've added some documentation to steer users to either use this async API or to use the low-level
serialx.create_serial_connectionAPI. The intermediateserialx.open_serial_connectionreturningStreamReaderandStreamWriteris clunky to use and error-prone, especially when it comes to open/close.Many unit tests have also been simplified to take advantage of this simpler API.