Преглед изворни кода

chore: switch to ruff, set minimum python version (#278)

J. Nick Koston пре 3 месеци
родитељ
комит
8f3172a216
4 измењених фајлова са 20 додато и 10 уклоњено
  1. 16 7
      .pre-commit-config.yaml
  2. 1 0
      setup.py
  3. 3 2
      switchbot/devices/device.py
  4. 0 1
      switchbot/devices/relay_switch.py

+ 16 - 7
.pre-commit-config.yaml

@@ -33,17 +33,26 @@ repos:
     hooks:
       - id: prettier
   - repo: https://github.com/asottile/pyupgrade
-    rev: v3.19.0
+    rev: v3.19.1
     hooks:
       - id: pyupgrade
-  - repo: https://github.com/PyCQA/isort
-    rev: 5.13.2
+        args: [--py311-plus]
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: v0.8.4
     hooks:
-      - id: isort
-  - repo: https://github.com/psf/black-pre-commit-mirror
-    rev: 24.10.0
+      - id: ruff
+        args: [--fix]
+      - id: ruff-format
+  - repo: https://github.com/cdce8p/python-typing-update
+    rev: v0.7.0
     hooks:
-      - id: black
+      - id: python-typing-update
+        stages: [manual]
+        args:
+          - --py311-plus
+          - --force
+          - --keep-updates
+        files: ^(switchbot)/.+\.py$
   - repo: https://github.com/codespell-project/codespell
     rev: v2.3.0
     hooks:

+ 1 - 0
setup.py

@@ -22,6 +22,7 @@ setup(
     author="Daniel Hjelseth Hoyer",
     url="https://github.com/sblibs/pySwitchbot/",
     license="MIT",
+    python_requires=">=3.11",
     classifiers=[
         "Development Status :: 3 - Alpha",
         "Environment :: Other Environment",

+ 3 - 2
switchbot/devices/device.py

@@ -8,7 +8,8 @@ import logging
 import time
 from dataclasses import replace
 from enum import Enum
-from typing import Any, Callable, TypeVar, cast
+from typing import Any, TypeVar, cast
+from collections.abc import Callable
 from uuid import UUID
 
 from bleak.backends.device import BLEDevice
@@ -470,7 +471,7 @@ class SwitchbotBaseDevice:
         timeout_expired = False
         try:
             notify_msg = await self._notify_future
-        except asyncio.TimeoutError:
+        except TimeoutError:
             timeout_expired = True
             raise
         finally:

+ 0 - 1
switchbot/devices/relay_switch.py

@@ -1,4 +1,3 @@
-import asyncio
 import logging
 import time
 from typing import Any