From 8b75a305e12d14575e7356d94c9cd46ca0e29391 Mon Sep 17 00:00:00 2001 From: Andrew Sayre <6730289+andrewsayre@users.noreply.github.com> Date: Mon, 5 Oct 2020 12:17:38 -0500 Subject: [PATCH] Update CI configuration and dependencies (#41) * Update CI * Change CI environment config * Update dependencies and lint --- .travis.yml | 17 ++++++++--------- pysmartthings/__init__.py | 32 ++++++-------------------------- pysmartthings/api.py | 18 +++++------------- pysmartthings/app.py | 6 +----- pysmartthings/device.py | 24 ++++-------------------- pysmartthings/errors.py | 5 +---- pysmartthings/location.py | 5 +---- pysmartthings/oauthtoken.py | 11 ++--------- pysmartthings/room.py | 5 +---- pysmartthings/scene.py | 5 +---- pysmartthings/smartthings.py | 22 +++++----------------- pysmartthings/subscription.py | 5 +---- test-requirements.txt | 18 +++++++++--------- tests/conftest.py | 3 ++- tests/test_app.py | 3 ++- tests/test_device.py | 14 ++++---------- tests/test_installedapp.py | 8 +++----- tests/test_location.py | 6 ++---- tests/test_oauthtoken.py | 9 +++------ tests/test_room.py | 11 +++-------- tests/test_scenes.py | 6 ++---- tests/test_smartthings.py | 9 +++------ tests/test_subscription.py | 7 ++----- tests/utilities.py | 6 +----- tox.ini | 2 +- 25 files changed, 73 insertions(+), 184 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9289288..2d0579a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,13 @@ language: python matrix: fast_finish: true include: - - python: '3.6' - env: TOXENV=lint - - python: '3.6' - env: TOXENV=cov - after_success: coveralls - - python: '3.7' - env: TOXENV=py37 - dist: xenial + - python: "3.8" + env: TOXENV=lint + - python: "3.8" + env: TOXENV=cov + after_success: coveralls + - python: "3.7" + env: TOXENV=py37 install: pip install -U tox coveralls script: tox deploy: @@ -21,4 +20,4 @@ deploy: skip_existing: true on: tags: true - condition: $TOXENV = lint \ No newline at end of file + condition: $TOXENV = lint diff --git a/pysmartthings/__init__.py b/pysmartthings/__init__.py index d0a50ce..06dea1a 100644 --- a/pysmartthings/__init__.py +++ b/pysmartthings/__init__.py @@ -20,10 +20,7 @@ Attribute, Capability, ) -from .const import ( # noqa - __title__, - __version__, -) +from .const import __title__, __version__ # noqa from .device import ( DEVICE_TYPE_DTH, DEVICE_TYPE_ENDPOINT_APP, @@ -36,36 +33,19 @@ DeviceStatus, DeviceStatusBase, ) -from .errors import ( - APIErrorDetail, - APIInvalidGrant, - APIResponseError, -) +from .errors import APIErrorDetail, APIInvalidGrant, APIResponseError from .installedapp import ( InstalledApp, InstalledAppEntity, InstalledAppStatus, InstalledAppType, ) -from .location import ( - Location, - LocationEntity, -) +from .location import Location, LocationEntity from .oauthtoken import OAuthToken -from .room import ( - Room, - RoomEntity, -) -from .scene import ( - Scene, - SceneEntity, -) +from .room import Room, RoomEntity +from .scene import Scene, SceneEntity from .smartthings import SmartThings -from .subscription import ( - SourceType, - Subscription, - SubscriptionEntity, -) +from .subscription import SourceType, Subscription, SubscriptionEntity __all__ = [ # app diff --git a/pysmartthings/api.py b/pysmartthings/api.py index 40ee7d1..fcf3ff6 100644 --- a/pysmartthings/api.py +++ b/pysmartthings/api.py @@ -1,18 +1,10 @@ """Utility for invoking the SmartThings Cloud API.""" -from aiohttp import ( - BasicAuth, - ClientSession, -) -from typing import ( - Optional, - Sequence, -) - -from .errors import ( - APIInvalidGrant, - APIResponseError, -) +from typing import Optional, Sequence + +from aiohttp import BasicAuth, ClientSession + +from .errors import APIInvalidGrant, APIResponseError API_OAUTH_TOKEN = "https://auth-global.api.smartthings.com/oauth/token" API_BASE = "https://api.smartthings.com/v1/" diff --git a/pysmartthings/app.py b/pysmartthings/app.py index 7417b81..ee64f70 100644 --- a/pysmartthings/app.py +++ b/pysmartthings/app.py @@ -1,11 +1,7 @@ """Define the app module.""" import re - -from typing import ( - List, - Optional, -) +from typing import List, Optional from .api import Api from .entity import Entity diff --git a/pysmartthings/device.py b/pysmartthings/device.py index 66656b6..cec0ebc 100644 --- a/pysmartthings/device.py +++ b/pysmartthings/device.py @@ -1,27 +1,11 @@ """Defines a SmartThings device.""" -from collections import ( - defaultdict, - namedtuple, -) -import re - +from collections import defaultdict, namedtuple import colorsys -from typing import ( - Any, - Dict, - Mapping, - Optional, - Sequence, - Tuple, -) +import re +from typing import Any, Dict, Mapping, Optional, Sequence, Tuple from .api import Api -from .capability import ( - ATTRIBUTE_OFF_VALUES, - ATTRIBUTE_ON_VALUES, - Attribute, - Capability, -) +from .capability import ATTRIBUTE_OFF_VALUES, ATTRIBUTE_ON_VALUES, Attribute, Capability from .entity import Entity DEVICE_TYPE_OCF = "OCF" diff --git a/pysmartthings/errors.py b/pysmartthings/errors.py index 7cd3e9e..fffa1d9 100644 --- a/pysmartthings/errors.py +++ b/pysmartthings/errors.py @@ -1,11 +1,8 @@ """Define errors that can be returned from the SmartThings API.""" import json +from typing import Optional, Sequence from aiohttp import ClientResponseError -from typing import ( - Optional, - Sequence, -) UNAUTHORIZED_ERROR = ( "Authorization for the API is required, but the request has not been " diff --git a/pysmartthings/location.py b/pysmartthings/location.py index bf3ceba..89eed41 100644 --- a/pysmartthings/location.py +++ b/pysmartthings/location.py @@ -1,9 +1,6 @@ """Define the SmartThing location.""" -from typing import ( - List, - Optional, -) +from typing import List, Optional from .api import Api from .entity import Entity diff --git a/pysmartthings/oauthtoken.py b/pysmartthings/oauthtoken.py index a6496bd..2ee9d6d 100644 --- a/pysmartthings/oauthtoken.py +++ b/pysmartthings/oauthtoken.py @@ -1,14 +1,7 @@ """Define the oauth module.""" -from datetime import ( - datetime, - timedelta, -) - -from typing import ( - List, - Optional, -) +from datetime import datetime, timedelta +from typing import List, Optional from .api import Api diff --git a/pysmartthings/room.py b/pysmartthings/room.py index cee5557..d9b2ef6 100644 --- a/pysmartthings/room.py +++ b/pysmartthings/room.py @@ -1,8 +1,5 @@ """Defines the rooms module.""" -from typing import ( - Dict, - Optional, -) +from typing import Dict, Optional from .api import Api from .entity import Entity diff --git a/pysmartthings/scene.py b/pysmartthings/scene.py index 7854a75..b814a3e 100644 --- a/pysmartthings/scene.py +++ b/pysmartthings/scene.py @@ -1,8 +1,5 @@ """Define the scene module.""" -from typing import ( - Dict, - Optional, -) +from typing import Dict, Optional from .api import Api from .entity import Entity diff --git a/pysmartthings/smartthings.py b/pysmartthings/smartthings.py index 4070edc..fd02110 100644 --- a/pysmartthings/smartthings.py +++ b/pysmartthings/smartthings.py @@ -1,11 +1,8 @@ """Define the SmartThings Cloud API.""" +from typing import List, Optional, Sequence + from aiohttp import ClientSession -from typing import ( - List, - Optional, - Sequence, -) from .api import Api from .app import ( @@ -19,21 +16,12 @@ AppSettingsEntity, ) from .device import DeviceEntity -from .installedapp import ( - InstalledAppEntity, - InstalledAppStatus, -) +from .installedapp import InstalledAppEntity, InstalledAppStatus from .location import LocationEntity from .oauthtoken import OAuthToken -from .room import ( - Room, - RoomEntity, -) +from .room import Room, RoomEntity from .scene import SceneEntity -from .subscription import ( - Subscription, - SubscriptionEntity, -) +from .subscription import Subscription, SubscriptionEntity class SmartThings: diff --git a/pysmartthings/subscription.py b/pysmartthings/subscription.py index c17e950..4a1160e 100644 --- a/pysmartthings/subscription.py +++ b/pysmartthings/subscription.py @@ -1,10 +1,7 @@ """Define the subscription module.""" from enum import Enum -from typing import ( - Any, - Optional, -) +from typing import Any, Optional from .api import Api from .entity import Entity diff --git a/test-requirements.txt b/test-requirements.txt index edaf480..0ce5a99 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,12 +1,12 @@ -black==19.10b0 -coveralls==2.1.1 -flake8==3.8.3 +black==20.8b1 +coveralls==2.1.2 +flake8==3.8.4 flake8-docstrings==1.5.0 -pydocstyle==5.0.2 -isort==4.2.5 -pylint==2.5.3 -pytest==5.4.3 +pydocstyle==5.1.1 +isort==5.5.4 +pylint==2.6.0 +pytest==6.1.1 pytest-asyncio==0.14.0 -pytest-cov==2.10.0 +pytest-cov==2.10.1 pytest-timeout==1.4.2 -yarl==1.4.2 \ No newline at end of file +yarl==1.6.0 \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index d215b93..c29843d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,8 @@ import glob import re +import pytest + from pysmartthings.api import ( API_APP, API_APP_OAUTH, @@ -27,7 +29,6 @@ Api, ) from pysmartthings.smartthings import SmartThings -import pytest from .utilities import ClientMocker diff --git a/tests/test_app.py b/tests/test_app.py index e19f85c..f2a93f7 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,5 +1,7 @@ """Define tests for the app module.""" +import pytest + from pysmartthings.app import ( APP_TYPE_LAMBDA, APP_TYPE_WEBHOOK, @@ -11,7 +13,6 @@ AppSettings, AppSettingsEntity, ) -import pytest from .conftest import APP_ID from .utilities import get_json diff --git a/tests/test_device.py b/tests/test_device.py index e008f7e..3a64e44 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -1,9 +1,8 @@ """Tests for the Device file.""" -from pysmartthings.capability import ( - Attribute, - Capability, -) +import pytest + +from pysmartthings.capability import Attribute, Capability from pysmartthings.device import ( DEVICE_TYPE_DTH, DEVICE_TYPE_UNKNOWN, @@ -12,13 +11,8 @@ DeviceStatus, Status, ) -import pytest -from .conftest import ( - DEVICE_ID, - LOCATION_ID, - ROOM_ID, -) +from .conftest import DEVICE_ID, LOCATION_ID, ROOM_ID from .utilities import get_json diff --git a/tests/test_installedapp.py b/tests/test_installedapp.py index 37aed46..890109a 100644 --- a/tests/test_installedapp.py +++ b/tests/test_installedapp.py @@ -1,17 +1,15 @@ """Tests for the installedapp module.""" +import pytest + from pysmartthings.installedapp import ( InstalledApp, InstalledAppEntity, InstalledAppStatus, InstalledAppType, ) -import pytest -from .conftest import ( - APP_ID, - INSTALLED_APP_ID, -) +from .conftest import APP_ID, INSTALLED_APP_ID from .utilities import get_json diff --git a/tests/test_location.py b/tests/test_location.py index e6395e0..4019f82 100644 --- a/tests/test_location.py +++ b/tests/test_location.py @@ -1,11 +1,9 @@ """Tests for the Location module.""" -from pysmartthings.location import ( - Location, - LocationEntity, -) import pytest +from pysmartthings.location import Location, LocationEntity + from .conftest import LOCATION_ID from .utilities import get_json diff --git a/tests/test_oauthtoken.py b/tests/test_oauthtoken.py index 6080a93..cd23512 100644 --- a/tests/test_oauthtoken.py +++ b/tests/test_oauthtoken.py @@ -1,13 +1,10 @@ """Tests for the OAuth module.""" -from pysmartthings.oauthtoken import OAuthToken import pytest -from .conftest import ( - CLIENT_ID, - CLIENT_SECRET, - REFRESH_TOKEN, -) +from pysmartthings.oauthtoken import OAuthToken + +from .conftest import CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN from .utilities import get_json diff --git a/tests/test_room.py b/tests/test_room.py index f00b19e..bd0c4c0 100644 --- a/tests/test_room.py +++ b/tests/test_room.py @@ -1,14 +1,9 @@ """Tests for the room module.""" -from pysmartthings.room import ( - Room, - RoomEntity, -) import pytest -from .conftest import ( - LOCATION_ID, - ROOM_ID, -) +from pysmartthings.room import Room, RoomEntity + +from .conftest import LOCATION_ID, ROOM_ID from .utilities import get_json diff --git a/tests/test_scenes.py b/tests/test_scenes.py index d63d0b1..85bf36c 100644 --- a/tests/test_scenes.py +++ b/tests/test_scenes.py @@ -1,10 +1,8 @@ """Tests for the scene module.""" -from pysmartthings.scene import ( - Scene, - SceneEntity, -) import pytest +from pysmartthings.scene import Scene, SceneEntity + from .utilities import get_json diff --git a/tests/test_smartthings.py b/tests/test_smartthings.py index 62f4d48..56e380d 100644 --- a/tests/test_smartthings.py +++ b/tests/test_smartthings.py @@ -1,13 +1,10 @@ """Tests for the SmartThings file.""" -from pysmartthings.app import ( - App, - AppOAuth, - AppSettings, -) +import pytest + +from pysmartthings.app import App, AppOAuth, AppSettings from pysmartthings.room import Room from pysmartthings.subscription import Subscription -import pytest from .conftest import ( APP_ID, diff --git a/tests/test_subscription.py b/tests/test_subscription.py index 38160e2..18be830 100644 --- a/tests/test_subscription.py +++ b/tests/test_subscription.py @@ -1,12 +1,9 @@ """Tests for the subscription module.""" -from pysmartthings.subscription import ( - SourceType, - Subscription, - SubscriptionEntity, -) import pytest +from pysmartthings.subscription import SourceType, Subscription, SubscriptionEntity + from .conftest import INSTALLED_APP_ID from .utilities import get_json diff --git a/tests/utilities.py b/tests/utilities.py index 8248569..46d8b1c 100644 --- a/tests/utilities.py +++ b/tests/utilities.py @@ -1,14 +1,10 @@ """Define testing utilities.""" import json as _json +from typing import Optional, Sequence, Union from urllib.parse import parse_qs from aiohttp import ClientSession from aiohttp.client_exceptions import ClientResponseError -from typing import ( - Optional, - Sequence, - Union, -) from yarl import URL BodyFixtureType = Optional[Union[str, list, dict]] diff --git a/tox.ini b/tox.ini index d91da86..ab6ab7c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint, cov, py37 +envlist = lint, cov, py38 skip_missing_interpreters = True [testenv]