add typing hints to make it easier for 3rd party developers to use the library (#90)

* add typing hints to make it easier for 3rd party developers to use the library

* remove unused devicetype enum to support python3.3

* add python 3.3 to travis and tox, install typing module in setup.py
This commit is contained in:
Teemu R
2017-09-18 18:13:06 +02:00
committed by GitHub
parent 3ddd31f3c1
commit af90a36153
11 changed files with 163 additions and 135 deletions

View File

@@ -1,11 +1,13 @@
from unittest import TestCase, skip, skipIf
from voluptuous import Schema, Invalid, All, Range
from functools import partial
from typing import Any, Dict # noqa: F401
from .. import SmartBulb, SmartDeviceException
from .fakes import (FakeTransportProtocol,
sysinfo_lb100, sysinfo_lb110,
sysinfo_lb120, sysinfo_lb130)
BULB_IP = '192.168.250.186'
SKIP_STATE_TESTS = False
@@ -24,7 +26,7 @@ def check_mode(x):
class TestSmartBulb(TestCase):
SYSINFO = sysinfo_lb130
SYSINFO = sysinfo_lb130 # type: Dict[str, Any]
# these schemas should go to the mainlib as
# they can be useful when adding support for new features/devices
# as well as to check that faked devices are operating properly.
@@ -172,7 +174,7 @@ class TestSmartBulb(TestCase):
def test_current_consumption(self):
x = self.bulb.current_consumption()
self.assertTrue(isinstance(x, int))
self.assertTrue(isinstance(x, float))
self.assertTrue(x >= 0.0)
def test_alias(self):

View File

@@ -3,6 +3,7 @@ from voluptuous import Schema, Invalid, All, Any, Range
from functools import partial
import datetime
import re
from typing import Dict # noqa: F401
from .. import SmartPlug, SmartDeviceException
from .fakes import (FakeTransportProtocol,
@@ -35,7 +36,7 @@ def check_mode(x):
class TestSmartPlugHS110(TestCase):
SYSINFO = sysinfo_hs110
SYSINFO = sysinfo_hs110 # type: Dict
# these schemas should go to the mainlib as
# they can be useful when adding support for new features/devices
# as well as to check that faked devices are operating properly.