Browse Source

fix: drop python 3.10 support since it does not have StrEnum (#242)

J. Nick Koston 2 weeks ago
parent
commit
93ecb3aabd
7 changed files with 97 additions and 40 deletions
  1. 16 15
      .github/workflows/ci.yaml
  2. 16 17
      .github/workflows/python-publish.yml
  3. 2 0
      .isort.cfg
  4. 50 0
      .pre-commit-config.yaml
  5. 6 6
      .travis.yml
  6. 4 1
      README.md
  7. 3 1
      scripts/get_encryption_key.py

+ 16 - 15
.github/workflows/ci.yaml

@@ -10,20 +10,21 @@ jobs:
 
     strategy:
       matrix:
-        python-version: ["3.10", "3.11", "3.12"]
+        python-version: ["3.11", "3.12"]
 
     steps:
-    - uses: actions/checkout@v4
-    - name: Set up Python
-      uses: actions/setup-python@v5
-      with:
-        python-version: ${{ matrix.python-version }}
-        cache: "pip"
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install -r requirements_dev.txt .
-    - name: Tests
-      run: pytest --cov=switchbot --cov-report=term-missing --cov-report=xml tests
-    - name: Upload coverage to Codecov
-      uses: codecov/codecov-action@v3
+      - uses: actions/checkout@v4
+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: ${{ matrix.python-version }}
+          cache: "pip"
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install -r requirements_dev.txt .
+      - uses: pre-commit/action@v3.0.0
+      - name: Tests
+        run: pytest --cov=switchbot --cov-report=term-missing --cov-report=xml tests
+      - name: Upload coverage to Codecov
+        uses: codecov/codecov-action@v3

+ 16 - 17
.github/workflows/python-publish.yml

@@ -8,23 +8,22 @@ on:
 
 jobs:
   deploy:
-
     runs-on: ubuntu-latest
 
     steps:
-    - uses: actions/checkout@v2
-    - name: Set up Python
-      uses: actions/setup-python@v2
-      with:
-        python-version: '3.x'
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install setuptools wheel twine
-    - name: Build and publish
-      env:
-        TWINE_USERNAME: __token__
-        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
-      run: |
-        python setup.py sdist bdist_wheel
-        twine upload --verbose dist/*
+      - uses: actions/checkout@v2
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: "3.x"
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install setuptools wheel twine
+      - name: Build and publish
+        env:
+          TWINE_USERNAME: __token__
+          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
+        run: |
+          python setup.py sdist bdist_wheel
+          twine upload --verbose dist/*

+ 2 - 0
.isort.cfg

@@ -0,0 +1,2 @@
+[settings]
+profile=black

+ 50 - 0
.pre-commit-config.yaml

@@ -0,0 +1,50 @@
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+exclude: "CHANGELOG.md"
+default_stages: [commit]
+
+ci:
+  autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
+  autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate"
+
+repos:
+  - repo: https://github.com/commitizen-tools/commitizen
+    rev: v3.2.2
+    hooks:
+      - id: commitizen
+        stages: [commit-msg]
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.5.0
+    hooks:
+      - id: debug-statements
+      - id: check-builtin-literals
+      - id: check-case-conflict
+      - id: check-docstring-first
+      - id: check-json
+      - id: check-toml
+      - id: check-xml
+      - id: check-yaml
+      - id: detect-private-key
+      - id: end-of-file-fixer
+      - id: trailing-whitespace
+      - id: debug-statements
+  - repo: https://github.com/pre-commit/mirrors-prettier
+    rev: v3.1.0
+    hooks:
+      - id: prettier
+  - repo: https://github.com/asottile/pyupgrade
+    rev: v3.15.0
+    hooks:
+      - id: pyupgrade
+  - repo: https://github.com/PyCQA/isort
+    rev: 5.13.2
+    hooks:
+      - id: isort
+  - repo: https://github.com/psf/black-pre-commit-mirror
+    rev: 23.12.1
+    hooks:
+      - id: black
+  - repo: https://github.com/codespell-project/codespell
+    rev: v2.2.6
+    hooks:
+      - id: codespell

+ 6 - 6
.travis.yml

@@ -2,14 +2,14 @@ sudo: false
 matrix:
   fast_finish: true
   include:
-  - python: '3.5'
-    env: TOXENV=lint
+    - python: "3.5"
+      env: TOXENV=lint
 cache:
   directories:
-  - "$HOME/.cache/pip"
+    - "$HOME/.cache/pip"
 install:
-- pip install flake8 pylint bluepy
+  - pip install flake8 pylint bluepy
 language: python
 script:
-- flake8 switchbot --max-line-length=120
-- pylint switchbot --max-line-length=120
+  - flake8 switchbot --max-line-length=120
+  - pylint switchbot --max-line-length=120

+ 4 - 1
README.md

@@ -1,10 +1,13 @@
 # pySwitchbot [![Build Status](https://travis-ci.org/Danielhiversen/pySwitchbot.svg?branch=master)](https://travis-ci.org/Danielhiversen/pySwitchbot)
+
 Library to control Switchbot IoT devices https://www.switch-bot.com/bot
 
 ## Obtaining locks encryption key
+
 Using the script `scripts/get_encryption_key.py` you can manually obtain locks encryption key.
 
 Usage:
+
 ```shell
 $ python3 get_encryption_key.py MAC USERNAME
 Key ID: xx
@@ -16,7 +19,7 @@ If authentication succeeds then script should output your key id and encryption
 
 Examples:
 
-* WoLock
+- WoLock
 
 ```python
 import asyncio

+ 3 - 1
scripts/get_encryption_key.py

@@ -16,7 +16,9 @@ def main():
         password = sys.argv[3]
 
     try:
-        result = SwitchbotLock.retrieve_encryption_key(sys.argv[1], sys.argv[2], password)
+        result = SwitchbotLock.retrieve_encryption_key(
+            sys.argv[1], sys.argv[2], password
+        )
     except RuntimeError as e:
         print(e)
         exit(1)