Browse Source

use python3.5-compatible type hints

https://github.com/fphammerle/switchbot-mqtt/pull/7/commits/d4294995c149c950c8e7a2f9a73756fcf5f2fb56
Fabian Peter Hammerle 3 years ago
parent
commit
213d2d7c2b
2 changed files with 7 additions and 3 deletions
  1. 4 0
      CHANGELOG.md
  2. 3 3
      systemctl_mqtt/__init__.py

+ 4 - 0
CHANGELOG.md

@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Fixed
+- Replaced [PEP526](https://www.python.org/dev/peps/pep-0526/#abstract)-style variable type hints
+  with [PEP484](https://www.python.org/dev/peps/pep-0484/)-compatible
+  to restore compatibility with python3.5
 
 ## [0.1.0] - 2020-06-16
 ### Added

+ 3 - 3
systemctl_mqtt/__init__.py

@@ -35,9 +35,9 @@ _SHUTDOWN_DELAY = datetime.timedelta(seconds=4)
 def _get_login_manager() -> dbus.proxies.Interface:
     # https://dbus.freedesktop.org/doc/dbus-python/tutorial.html
     bus = dbus.SystemBus()
-    proxy: dbus.proxies.ProxyObject = bus.get_object(
+    proxy = bus.get_object(
         bus_name="org.freedesktop.login1", object_path="/org/freedesktop/login1"
-    )
+    )  # type: dbus.proxies.ProxyObject
     # https://freedesktop.org/wiki/Software/systemd/logind/
     return dbus.Interface(object=proxy, dbus_interface="org.freedesktop.login1.Manager")
 
@@ -85,7 +85,7 @@ _MQTT_TOPIC_SUFFIX_ACTION_MAPPING = {
 class _Settings:
     # pylint: disable=too-few-public-methods
     def __init__(self, mqtt_topic_prefix: str) -> None:
-        self.mqtt_topic_action_mapping: typing.Dict[str, typing.Callable] = {}
+        self.mqtt_topic_action_mapping = {}  # type: typing.Dict[str, typing.Callable]
         for topic_suffix, action in _MQTT_TOPIC_SUFFIX_ACTION_MAPPING.items():
             topic = mqtt_topic_prefix + "/" + topic_suffix
             self.mqtt_topic_action_mapping[topic] = action