Add async_iterator util#153194
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull Request Overview
This PR extracts async iterator utility classes from the backup integration and moves them to a shared location in homeassistant.util.async_iterator, making them available for reuse across the codebase.
- Adds new
AsyncIteratorReaderandAsyncIteratorWriterclasses tohomeassistant/util/async_iterator.py - Updates the backup integration to use the shared utilities instead of local implementations
- Replaces the backup-specific
AbortCipherexception with a genericAbortexception
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
homeassistant/util/async_iterator.py |
New module containing AsyncIteratorReader, AsyncIteratorWriter classes and Abort exception |
tests/util/test_async_iterator.py |
Comprehensive test suite for the new async iterator utilities |
homeassistant/components/backup/util.py |
Removes local implementations and imports from shared module, updates exception handling |
homeassistant/components/backup/manager.py |
Updates import and constructor call to use shared AsyncIteratorReader |
homeassistant/components/backup/http.py |
Updates imports and constructor calls to use shared utilities |
| """Close the iterator.""" | ||
|
|
There was a problem hiding this comment.
The close method has an empty implementation. Consider adding documentation to clarify that this is intentionally a no-op or implement proper cleanup if needed.
| """Close the iterator.""" | |
| """Close the iterator. | |
| This method is intentionally a no-op as no cleanup is required. | |
| """ |
Proposed change
Add async_iterator util with classes
AsyncIteratorReaderandAsyncIteratorWriterRationale: The helper classes are useful outside the backup integration
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: