megakid / ha_octopus_intelligent

Apache License 2.0
86 stars 10 forks source link

Cannot Import Name Override #43

Closed Puntoboy closed 4 months ago

Puntoboy commented 4 months ago

Updated to the latest version today, Since rebooting HA I get this error.

Logger: homeassistant.setup Source: setup.py:251 First occurred: 15:31:29 (1 occurrences) Last logged: 15:31:29

Setup failed for custom integration 'octopus_intelligent': Unable to import component: cannot import name 'override' from 'typing' (/usr/local/lib/python3.11/typing.py) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component component = integration.get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 822, in get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/config/custom_components/octopus_intelligent/init.py", line 3, in from .octopus_intelligent_system import OctopusIntelligentSystem File "/config/custom_components/octopus_intelligent/octopus_intelligent_system.py", line 3, in from typing import Any, override ImportError: cannot import name 'override' from 'typing' (/usr/local/lib/python3.11/typing.py)

pdcastro commented 4 months ago

Thanks for reporting it @Puntoboy 👍 The fix is ready in PR #44, waiting for @megakid’s review and approval. Meanwhile, what you can do:

Issue background: It’s my bad. I added the @override annotation in PR #37 without realising that it is was only introduced in Python 3.12. This integration should still support Python 3.11 as well.

Puntoboy commented 4 months ago

Thank you for the quick update.

I didn't realised 2024.2.0 was the minimum cut off, I need to upgrade my install soon anyway so I'll do that. I'm currently on 2024.1.5.

pdcastro commented 4 months ago

Fixed in release v1.7.1, already available through HACS (custom repositories) as well.