Browse Source

dev env: upgrade black

Fabian Peter Hammerle 3 years ago
parent
commit
7ff05ba3f2
6 changed files with 45 additions and 48 deletions
  1. 4 3
      Pipfile
  2. 28 28
      Pipfile.lock
  3. 5 1
      setup.py
  4. 2 4
      switchbot_mqtt/__init__.py
  5. 1 1
      tests/test_cli.py
  6. 5 11
      tests/test_mqtt.py

+ 4 - 3
Pipfile

@@ -9,7 +9,7 @@ switchbot-mqtt = {editable = true,path = "."}
 [dev-packages]
 # black requires python>=3.6
 # https://github.com/psf/black/commit/e74117f172e29e8a980e2c9de929ad50d3769150#diff-2eeaed663bd0d25b7e608891384b7298R51
-black = {version = "==19.10b0", markers = "python_version >= '3.6'"}
+black = {version = "==20.8b1", markers = "python_version >= '3.6'"}
 mypy = "*"
 pylint = "*"
 pylint-import-requirements = "*"
@@ -17,10 +17,11 @@ pytest = "*"
 pytest-cov = "*"
 
 # python3.5 compatibility
-# https://github.com/jaraco/zipp/commit/05a3c52b4d41690e0471a2e283cffb500dc0329a
-zipp = "<2"
+isort = "<5"
 # workaround https://github.com/pytest-dev/pytest/issues/3953
 pathlib2 = {version = "*", markers="python_version < '3.6'"}
+# https://github.com/jaraco/zipp/commit/05a3c52b4d41690e0471a2e283cffb500dc0329a
+zipp = "<2"
 
 # python3.8 compatibility
 # workaround https://github.com/WanzenBug/pylint-import-requirements/issues/17

+ 28 - 28
Pipfile.lock

@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "0aa6286b8436c819681eb7a32676e5163af9a562d2340a69854743d51089c421"
+            "sha256": "6bac2bcb0a3efdcf26562e9050770ff185a8a2440dce6697a4c6478e5954f238"
         },
         "pipfile-spec": 6,
         "requires": {
@@ -63,12 +63,11 @@
         },
         "black": {
             "hashes": [
-                "sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b",
-                "sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539"
+                "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"
             ],
             "index": "pypi",
             "markers": "python_version >= '3.6'",
-            "version": "==19.10b0"
+            "version": "==20.8b1"
         },
         "click": {
             "hashes": [
@@ -118,11 +117,11 @@
         },
         "importlib-metadata": {
             "hashes": [
-                "sha256:0505dd08068cfec00f53a74a0ad927676d7757da81b7436a6eefe4c7cf75c545",
-                "sha256:15ec6c0fd909e893e3a08b3a7c76ecb149122fb14b7efe1199ddd4c7c57ea958"
+                "sha256:77a540690e24b0305878c37ffd421785a6f7e53c8b5720d211b211de8d0e95da",
+                "sha256:cefa1a2f919b866c5beb7c9f7b0ebb4061f30a8a9bf16d609b000e2dfaceb9c3"
             ],
             "index": "pypi",
-            "version": "==1.6.1"
+            "version": "==2.0.0"
         },
         "iniconfig": {
             "hashes": [
@@ -136,6 +135,7 @@
                 "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1",
                 "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"
             ],
+            "index": "pypi",
             "version": "==4.3.21"
         },
         "lazy-object-proxy": {
@@ -173,23 +173,23 @@
         },
         "mypy": {
             "hashes": [
-                "sha256:00cb1964a7476e871d6108341ac9c1a857d6bd20bf5877f4773ac5e9d92cd3cd",
-                "sha256:127de5a9b817a03a98c5ae8a0c46a20dc44442af6dcfa2ae7f96cb519b312efa",
-                "sha256:1f3976a945ad7f0a0727aafdc5651c2d3278e3c88dee94e2bf75cd3386b7b2f4",
-                "sha256:2f8c098f12b402c19b735aec724cc9105cc1a9eea405d08814eb4b14a6fb1a41",
-                "sha256:4ef13b619a289aa025f2273e05e755f8049bb4eaba6d703a425de37d495d178d",
-                "sha256:5d142f219bf8c7894dfa79ebfb7d352c4c63a325e75f10dfb4c3db9417dcd135",
-                "sha256:62eb5dd4ea86bda8ce386f26684f7f26e4bfe6283c9f2b6ca6d17faf704dcfad",
-                "sha256:64c36eb0936d0bfb7d8da49f92c18e312ad2e3ed46e5548ae4ca997b0d33bd59",
-                "sha256:75eed74d2faf2759f79c5f56f17388defd2fc994222312ec54ee921e37b31ad4",
-                "sha256:974bebe3699b9b46278a7f076635d219183da26e1a675c1f8243a69221758273",
-                "sha256:a5e5bb12b7982b179af513dddb06fca12285f0316d74f3964078acbfcf4c68f2",
-                "sha256:d31291df31bafb997952dc0a17ebb2737f802c754aed31dd155a8bfe75112c57",
-                "sha256:d3b4941de44341227ece1caaf5b08b23e42ad4eeb8b603219afb11e9d4cfb437",
-                "sha256:eadb865126da4e3c4c95bdb47fe1bb087a3e3ea14d39a3b13224b8a4d9f9a102"
+                "sha256:0a0d102247c16ce93c97066443d11e2d36e6cc2a32d8ccc1f705268970479324",
+                "sha256:0d34d6b122597d48a36d6c59e35341f410d4abfa771d96d04ae2c468dd201abc",
+                "sha256:2170492030f6faa537647d29945786d297e4862765f0b4ac5930ff62e300d802",
+                "sha256:2842d4fbd1b12ab422346376aad03ff5d0805b706102e475e962370f874a5122",
+                "sha256:2b21ba45ad9ef2e2eb88ce4aeadd0112d0f5026418324176fd494a6824b74975",
+                "sha256:72060bf64f290fb629bd4a67c707a66fd88ca26e413a91384b18db3876e57ed7",
+                "sha256:af4e9ff1834e565f1baa74ccf7ae2564ae38c8df2a85b057af1dbbc958eb6666",
+                "sha256:bd03b3cf666bff8d710d633d1c56ab7facbdc204d567715cb3b9f85c6e94f669",
+                "sha256:c614194e01c85bb2e551c421397e49afb2872c88b5830e3554f0519f9fb1c178",
+                "sha256:cf4e7bf7f1214826cf7333627cb2547c0db7e3078723227820d0a2490f117a01",
+                "sha256:da56dedcd7cd502ccd3c5dddc656cb36113dd793ad466e894574125945653cea",
+                "sha256:e86bdace26c5fe9cf8cb735e7cedfe7850ad92b327ac5d797c656717d2ca66de",
+                "sha256:e97e9c13d67fbe524be17e4d8025d51a7dca38f90de2e462243ab8ed8a9178d1",
+                "sha256:eea260feb1830a627fb526d22fbb426b750d9f5a47b624e8d5e7e004359b219c"
             ],
             "index": "pypi",
-            "version": "==0.780"
+            "version": "==0.790"
         },
         "mypy-extensions": {
             "hashes": [
@@ -237,11 +237,11 @@
         },
         "pylint": {
             "hashes": [
-                "sha256:7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc",
-                "sha256:d0ece7d223fe422088b0e8f13fa0a1e8eb745ebffcb8ed53d3e95394b6101a1c"
+                "sha256:bb4a908c9dadbc3aac18860550e870f58e1a02c9f2c204fdf5693d73be061210",
+                "sha256:bfe68f020f8a0fece830a22dd4d5dddb4ecc6137db04face4c3420a46a52239f"
             ],
             "index": "pypi",
-            "version": "==2.5.3"
+            "version": "==2.6.0"
         },
         "pylint-import-requirements": {
             "hashes": [
@@ -268,11 +268,11 @@
         },
         "pytest-cov": {
             "hashes": [
-                "sha256:1a629dc9f48e53512fcbfda6b07de490c374b0c83c55ff7a1720b3fccff0ac87",
-                "sha256:6e6d18092dce6fad667cd7020deed816f858ad3b49d5b5e2b1cc1c97a4dba65c"
+                "sha256:45ec2d5182f89a81fc3eb29e3d1ed3113b9e9a873bcddb2a71faaab066110191",
+                "sha256:47bd0ce14056fdd79f93e1713f88fad7bdcc583dcd7783da86ef2f085a0bb88e"
             ],
             "index": "pypi",
-            "version": "==2.10.0"
+            "version": "==2.10.1"
         },
         "regex": {
             "hashes": [

+ 5 - 1
setup.py

@@ -67,7 +67,11 @@ setuptools.setup(
         "Programming Language :: Python :: 3.8",
         "Topic :: Home Automation",
     ],
-    entry_points={"console_scripts": ["switchbot-mqtt = switchbot_mqtt:_main",]},
+    entry_points={
+        "console_scripts": [
+            "switchbot-mqtt = switchbot_mqtt:_main",
+        ]
+    },
     install_requires=["PySwitchbot", "paho-mqtt<2"],
     setup_requires=["setuptools_scm"],
     tests_require=["pytest"],

+ 2 - 4
switchbot_mqtt/__init__.py

@@ -88,7 +88,7 @@ def _report_state(
     payload = _MQTT_STATE_PAYLOAD_MAPPING[switchbot_state]
     _LOGGER.debug("publishing topic=%s payload=%r", topic, payload)
     message_info = mqtt_client.publish(
-        topic=topic, payload=payload, retain=True,
+        topic=topic, payload=payload, retain=True
     )  # type: paho.mqtt.client.MQTTMessageInfo
     if message_info.rc != paho.mqtt.client.MQTT_ERR_SUCCESS:
         _LOGGER.error("failed to publish state (rc=%d)", message_info.rc)
@@ -174,9 +174,7 @@ def _run(
     mqtt_client = paho.mqtt.client.Client()
     mqtt_client.on_connect = _mqtt_on_connect
     mqtt_client.on_message = _mqtt_on_message
-    _LOGGER.info(
-        "connecting to MQTT broker %s:%d", mqtt_host, mqtt_port,
-    )
+    _LOGGER.info("connecting to MQTT broker %s:%d", mqtt_host, mqtt_port)
     if mqtt_username:
         mqtt_client.username_pw_set(username=mqtt_username, password=mqtt_password)
     elif mqtt_password:

+ 1 - 1
tests/test_cli.py

@@ -69,7 +69,7 @@ def test__main(
 
 
 @pytest.mark.parametrize(
-    ("password_file_content", "expected_password",),
+    ("password_file_content", "expected_password"),
     [
         ("secret", "secret"),
         ("secret space", "secret space"),

+ 5 - 11
tests/test_mqtt.py

@@ -51,7 +51,7 @@ def test__run_authentication(mqtt_host, mqtt_port, mqtt_username, mqtt_password)
         )
     mqtt_client_mock.assert_called_once_with()
     mqtt_client_mock().username_pw_set.assert_called_once_with(
-        username=mqtt_username, password=mqtt_password,
+        username=mqtt_username, password=mqtt_password
     )
 
 
@@ -131,9 +131,7 @@ def test__mqtt_on_message(
         (b"homeassistant/switch/switchbot/aa:bb:cc:dd:ee:ff/set", b"EIN"),
     ],
 )
-def test__mqtt_on_message_ignored(
-    topic: bytes, payload: bytes,
-):
+def test__mqtt_on_message_ignored(topic: bytes, payload: bytes):
     message = MQTTMessage(topic=topic)
     message.payload = payload
     with unittest.mock.patch("switchbot_mqtt._send_command") as send_command_mock:
@@ -145,9 +143,7 @@ def test__mqtt_on_message_ignored(
     ("topic", "payload"),
     [(b"homeassistant/switch/switchbot/aa:bb:cc:dd:ee:ff/set", b"ON")],
 )
-def test__mqtt_on_message_ignored_retained(
-    topic: bytes, payload: bytes,
-):
+def test__mqtt_on_message_ignored_retained(topic: bytes, payload: bytes):
     message = MQTTMessage(topic=topic)
     message.payload = payload
     message.retain = True
@@ -168,9 +164,7 @@ def test__mqtt_on_message_ignored_retained(
         (switchbot_mqtt._SwitchbotState.OFF, b"OFF"),
     ],
 )
-@pytest.mark.parametrize(
-    "return_code", [MQTT_ERR_SUCCESS, MQTT_ERR_QUEUE_SIZE],
-)
+@pytest.mark.parametrize("return_code", [MQTT_ERR_SUCCESS, MQTT_ERR_QUEUE_SIZE])
 def test__report_state(
     caplog,
     state: switchbot_mqtt._SwitchbotState,
@@ -189,7 +183,7 @@ def test__report_state(
             switchbot_state=state,
         )
     mqtt_client_mock.publish.assert_called_once_with(
-        topic=expected_topic, payload=expected_payload, retain=True,
+        topic=expected_topic, payload=expected_payload, retain=True
     )
     if return_code == MQTT_ERR_SUCCESS:
         assert len(caplog.records) == 0