Skip to content
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

Replace async_timeout library and simplify platform setup loop #42

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

pdcastro
Copy link
Collaborator

@pdcastro pdcastro commented Mar 5, 2024

async_timeout is a third-party library installed through PyPI / pip install. It was written in 2016, around the time when Python 3.6 was released. At that time, Python’s asyncio built-in module had a wait_for() function but not a timeout() function. In 2022, Python 3.11 was released including a drop-in replacement for the async_timeout library through the built-in asyncio.timeout() function. Other things equal, a built-in function is preferable to a third-party PyPI library.

Meanwhile, Home Assistant dropped support for Python versions 3.10 and older in HASS version 2023.8.0 (Aug 2023). It now requires Python versions 3.11 or 3.12.

Also, the async_timeout library is not being declared as a dependency in this integration’s manifest.json file, so Home Assistant is not making sure that async_timeout is installed alongside this integration. It has been working so far because other common Home Assistant integrations still declare async_timeout as a dependency.

This PR also proposes a simplification to the platform setup loop using the async_forward_entry_setups() function added to Home Assistant 2022.8.0 (Aug 2022), and a couple of log message amendments.

@pdcastro pdcastro merged commit 13d548f into megakid:main Mar 15, 2024
2 checks passed
@pdcastro pdcastro deleted the replace_async_timeout branch March 15, 2024 12:43
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