Browse Source

fix "TypeError: 'ABCMeta' object is not subscriptable" on python<3.9

Fabian Peter Hammerle 2 years ago
parent
commit
878afa9bf6
3 changed files with 3 additions and 6 deletions
  1. 1 2
      setup.py
  2. 1 2
      switchbot_mqtt/_actors/_base.py
  3. 1 2
      switchbot_mqtt/_utils.py

+ 1 - 2
setup.py

@@ -72,8 +72,7 @@ setuptools.setup(
         "Topic :: Home Automation",
     ],
     entry_points={"console_scripts": ["switchbot-mqtt = switchbot_mqtt._cli:_main"]},
-    # >=3.6 variable type hints, f-strings, collections.abc.Collection
-    #       & * to force keyword-only arguments
+    # >=3.6 variable type hints, f-strings, typing.Collection & * to force keyword-only arguments
     # >=3.7 postponed evaluation of type annotations (PEP563) & dataclass
     python_requires=">=3.7",
     install_requires=[

+ 1 - 2
switchbot_mqtt/_actors/_base.py

@@ -19,7 +19,6 @@
 from __future__ import annotations  # PEP563 (default in python>=3.10)
 
 import abc
-import collections.abc
 import dataclasses
 import logging
 import queue
@@ -138,7 +137,7 @@ class _MQTTControlledActor(abc.ABC):
         cls,
         userdata: _MQTTCallbackUserdata,
         topic: str,
-        expected_topic_levels: collections.abc.Collection[_MQTTTopicLevel],
+        expected_topic_levels: typing.Collection[_MQTTTopicLevel],
     ) -> typing.Optional[_MQTTControlledActor]:
         try:
             mac_address = _parse_mqtt_topic(

+ 1 - 2
switchbot_mqtt/_utils.py

@@ -16,7 +16,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-import collections.abc
 import enum
 import logging
 import queue  # pylint: disable=unused-import; in type hint
@@ -47,7 +46,7 @@ def _join_mqtt_topic_levels(
 
 
 def _parse_mqtt_topic(
-    topic: str, expected_levels: collections.abc.Collection[_MQTTTopicLevel]
+    topic: str, expected_levels: typing.Collection[_MQTTTopicLevel]
 ) -> typing.Dict[_MQTTTopicPlaceholder, str]:
     attrs: typing.Dict[_MQTTTopicPlaceholder, str] = {}
     topic_split = topic.split("/")