Skip to content

fix: import Any in core/device.py (integration fails to import on v0.4.11) - #232

Merged
sususweet merged 1 commit into
sususweet:masterfrom
zealllot:fix-device-any-import
Jul 23, 2026
Merged

fix: import Any in core/device.py (integration fails to import on v0.4.11)#232
sususweet merged 1 commit into
sususweet:masterfrom
zealllot:fix-device-any-import

Conversation

@zealllot

Copy link
Copy Markdown
Contributor

Fixes #231

core/device.py line 306 uses Any in a return annotation:

def _get_existing_attr_value(self, attrs: dict, key: str) -> Any:

but the module never imports it. Annotations on methods are evaluated when the class body executes, so the module raises NameError: name 'Any' is not defined at import time and the whole integration fails to set up ("Invalid config") after updating to v0.4.11.

This PR adds the missing from typing import Any.

Verified on HA 2026.1.3 (Python 3.13): with this one-line patch applied, the integration imports and all entities recover after a config-entry reload.

🤖 Generated with Claude Code

…4.11)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sususweet
sususweet merged commit 50a99b9 into sususweet:master Jul 23, 2026
2 checks passed
@sususweet

Copy link
Copy Markdown
Owner

Thanks for the quick fix – and for catching this!

You're absolutely right: typing.Any was used in the return annotation on line 306 of core/device.py but never imported. Since annotations are evaluated at class definition time (unless from __future__ import annotations is used), this would indeed raise a NameError and break the entire integration on import – exactly as you described.

The one‑line fix is clean and correct. I've verified that from typing import Any is now present and the annotation resolves properly.

Merging – will be included in the next patch release.

Thanks again for the prompt report and fix! 🚀

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.

v0.4.11: NameError: name 'Any' is not defined in core/device.py — integration fails to import

2 participants