From 983fd580781d7f347e084b36b7c580ccb2d1de8c Mon Sep 17 00:00:00 2001 From: mib1185 Date: Sun, 5 May 2024 10:48:30 +0000 Subject: [PATCH 1/4] drop 3.8 add 3.11 and 3.12 --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 51 +++++++++++++++++---------------- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 13 +++++---- .vscode/settings.default.json | 6 +--- pyproject.toml | 5 ++-- requirements_dev.txt | 2 +- 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index be06aeef..d61ea0ce 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.8 +FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.9 # install test requirements COPY requirements*.txt /tmp/pip-tmp/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b86a0937..31cd7a11 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,30 +5,33 @@ "postCreateCommand": "scripts/setup", "containerEnv": { "DEVCONTAINER": "1" }, "runArgs": ["-e", "GIT_EDITOR=code --wait"], - "extensions": [ - "ms-python.vscode-pylance", - "visualstudioexptteam.vscodeintellicode", - "esbenp.prettier-vscode" - ], - // Please keep this file in sync with settings in .vscode/settings.default.json - "settings": { - "python.pythonPath": "/usr/local/bin/python", - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.formatting.provider": "black", - "python.testing.pytestArgs": ["tests"], - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true, - "python.linting.mypyEnabled": true, - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true, - "terminal.integrated.profiles.linux": { - "zsh": { - "path": "/usr/bin/zsh" + "customizations": { + "vscode": { + "extensions": [ + "ms-python.vscode-pylance", + "ms-python.black-formatter", + "ms-python.pylint", + "ms-python.mypy-type-checker", + "visualstudioexptteam.vscodeintellicode", + "esbenp.prettier-vscode" + ], + // Please keep this file in sync with settings in .vscode/settings.default.json + "settings": { + "python.pythonPath": "/usr/local/bin/python", + "python.testing.pytestArgs": ["tests"], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true, + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh" } - }, - "terminal.integrated.defaultProfile.linux": "zsh" + } } } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8cdba033..18c4806b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5.1.0 with: - python-version: "3.10" + python-version: "3.12" - name: Install build dependencies run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 85f5ae60..a4fec48b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,10 +13,10 @@ jobs: - name: Check out the repository uses: actions/checkout@v4.1.4 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v5.1.0 with: - python-version: "3.8" + python-version: "3.9" - name: Install dependencies run: | @@ -55,9 +55,10 @@ jobs: fail-fast: false matrix: include: - - python-version: "3.8" - python-version: "3.9" - python-version: "3.10" + - python-version: "3.11" + - python-version: "3.12" steps: - name: Check out the repository @@ -90,10 +91,10 @@ jobs: - name: Check out the repository uses: actions/checkout@v4.1.4 - - name: Set up Python 3.10 + - name: Set up Python 3.12 uses: actions/setup-python@v5.1.0 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies run: | @@ -128,7 +129,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5.1.0 with: - python-version: "3.10" + python-version: "3.12" - name: Install build dependencies run: | diff --git a/.vscode/settings.default.json b/.vscode/settings.default.json index 27c3a3f6..d969f962 100644 --- a/.vscode/settings.default.json +++ b/.vscode/settings.default.json @@ -1,9 +1,5 @@ { - "python.formatting.provider": "black", - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, "python.testing.pytestArgs": ["tests"], "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true, - "python.linting.mypyEnabled": true + "python.testing.pytestEnabled": true } diff --git a/pyproject.toml b/pyproject.toml index 15d5069d..dbc6895f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,13 +18,14 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Software Development :: Libraries", ] keywords=["synology-dsm", "synology"] -requires-python = ">=3.8.0" +requires-python = ">=3.9" dependencies = ["aiohttp"] [project.urls] diff --git a/requirements_dev.txt b/requirements_dev.txt index 04e013b7..dd4fdb10 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -9,7 +9,7 @@ flake8==7.0.0 mypy==1.10.0 pep8-naming==0.13.3 pre-commit-hooks==4.6.0 -pre-commit==3.2.2 +pre-commit==3.7.0 Pygments==2.17.2 pylint==3.1.0 pytest-asyncio==0.20.3 From b26e5d1290c457b6961a812509824fa7dfedc862 Mon Sep 17 00:00:00 2001 From: mib1185 Date: Sun, 5 May 2024 11:17:38 +0000 Subject: [PATCH 2/4] exclude tests from mypy --- .devcontainer/devcontainer.json | 1 + .vscode/settings.default.json | 3 ++- pyproject.toml | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 31cd7a11..4980aab5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,6 +21,7 @@ "python.testing.pytestArgs": ["tests"], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, + "mypy-type-checker.args": ["--config-file=pyproject.toml"], "editor.formatOnPaste": false, "editor.formatOnSave": true, "editor.formatOnType": true, diff --git a/.vscode/settings.default.json b/.vscode/settings.default.json index d969f962..89e87041 100644 --- a/.vscode/settings.default.json +++ b/.vscode/settings.default.json @@ -1,5 +1,6 @@ { "python.testing.pytestArgs": ["tests"], "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "mypy-type-checker.args": ["--config-file=pyproject.toml"] } diff --git a/pyproject.toml b/pyproject.toml index dbc6895f..93b68e25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,9 @@ fail_under = 80 profile = "black" src_paths = ["src", "tests"] +[tool.mypy] +exclude = ["tests/"] + [tool.pylint.MAIN] ignore = ["tests"] From ccebd845f734798fea2e657f7e0e9200d63b192b Mon Sep 17 00:00:00 2001 From: mib1185 Date: Sun, 5 May 2024 11:29:30 +0000 Subject: [PATCH 3/4] add some more test coverage --- tests/test_synology_dsm_7.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_synology_dsm_7.py b/tests/test_synology_dsm_7.py index d3ffef7c..46e0f7bb 100644 --- a/tests/test_synology_dsm_7.py +++ b/tests/test_synology_dsm_7.py @@ -3,6 +3,18 @@ # pylint: disable=protected-access import pytest +from synology_dsm.api.core.external_usb import SynoCoreExternalUSB +from synology_dsm.api.core.security import SynoCoreSecurity +from synology_dsm.api.core.share import SynoCoreShare +from synology_dsm.api.core.system import SynoCoreSystem +from synology_dsm.api.core.upgrade import SynoCoreUpgrade +from synology_dsm.api.core.utilization import SynoCoreUtilization +from synology_dsm.api.download_station import SynoDownloadStation +from synology_dsm.api.dsm.information import SynoDSMInformation +from synology_dsm.api.dsm.network import SynoDSMNetwork +from synology_dsm.api.photos import SynoPhotos +from synology_dsm.api.storage.storage import SynoStorage +from synology_dsm.api.surveillance_station import SynoSurveillanceStation from synology_dsm.const import API_AUTH from synology_dsm.exceptions import SynologyDSMLogin2SARequiredException @@ -15,6 +27,7 @@ VALID_USER_2SA, SynologyDSMMock, ) +from .api_data.dsm_7 import DSM_7_API_INFO from .const import DEVICE_TOKEN, SESSION_ID, SYNO_TOKEN @@ -28,6 +41,20 @@ async def test_login(self, dsm_7): assert dsm_7.apis.get(API_AUTH) assert dsm_7._session_id == SESSION_ID assert dsm_7._syno_token == SYNO_TOKEN + assert dsm_7.device_token is None + assert dsm_7.apis == DSM_7_API_INFO["data"] + assert isinstance(dsm_7.download_station, SynoDownloadStation) + assert isinstance(dsm_7.external_usb, SynoCoreExternalUSB) + assert isinstance(dsm_7.information, SynoDSMInformation) + assert isinstance(dsm_7.network, SynoDSMNetwork) + assert isinstance(dsm_7.photos, SynoPhotos) + assert isinstance(dsm_7.security, SynoCoreSecurity) + assert isinstance(dsm_7.share, SynoCoreShare) + assert isinstance(dsm_7.storage, SynoStorage) + assert isinstance(dsm_7.surveillance_station, SynoSurveillanceStation) + assert isinstance(dsm_7.system, SynoCoreSystem) + assert isinstance(dsm_7.upgrade, SynoCoreUpgrade) + assert isinstance(dsm_7.utilisation, SynoCoreUtilization) @pytest.mark.asyncio async def test_login_2sa(self): From 65ba8d3b1fe1a2336ba18b764ddb39b5c9a76b29 Mon Sep 17 00:00:00 2001 From: mib1185 Date: Sun, 5 May 2024 11:31:10 +0000 Subject: [PATCH 4/4] add coverage vscode task --- .vscode/tasks.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7023ac43..b8caae23 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,6 +12,15 @@ "isDefault": true } }, + { + "label": "coverage", + "type": "shell", + "command": "coverage run --parallel -m pytest ; coverage combine ; coverage report", + "group": { + "kind": "test", + "isDefault": false + } + }, { "label": "reinstall dependencies", "type": "shell",