From 5dc94cd5c89ef7a5860bd4d8640fbc08a102d181 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Tue, 17 Jan 2017 14:38:44 +0100 Subject: [PATCH] Add flake8 to tox, disable qa on pyHS100/__init__.py, fix py27 compatibility (#31) --- pyHS100/__init__.py | 1 + pyHS100/pyHS100.py | 3 ++- tox.ini | 13 +++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pyHS100/__init__.py b/pyHS100/__init__.py index 26c45dd5..4f040744 100644 --- a/pyHS100/__init__.py +++ b/pyHS100/__init__.py @@ -1,3 +1,4 @@ +# flake8: noqa from __future__ import absolute_import from __future__ import unicode_literals from pyHS100.pyHS100 import SmartBulb, SmartPlug, TPLinkSmartHomeProtocol, SmartPlugException diff --git a/pyHS100/pyHS100.py b/pyHS100/pyHS100.py index 81c1804b..eaaccb90 100644 --- a/pyHS100/pyHS100.py +++ b/pyHS100/pyHS100.py @@ -17,6 +17,7 @@ http://www.apache.org/licenses/LICENSE-2.0 # python2 compatibility from __future__ import absolute_import from __future__ import unicode_literals +from future.utils import raise_from try: basestring except NameError: @@ -70,7 +71,7 @@ class SmartDevice(object): request={target: {cmd: arg}} ) except Exception as ex: - raise SmartPlugException(ex) from ex + raise_from(SmartPlugException(), ex) if target not in response: raise SmartPlugException("No required {} in response: {}".format(target, response)) diff --git a/tox.ini b/tox.ini index 293d0232..96613544 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,22 @@ [tox] -envlist=py27,py34,py35 +envlist=py27,py34,py35,py36,flake8 [tox:travis] 2.7 = py27 3.4 = py34 3.5 = py35 +3.6 = py36 + [testenv] deps= future pytest voluptuous -commands=py.test +commands=py.test pyHS100 + +[testenv:flake8] +deps=flake8 +commands=flake8 pyHS100 + +[flake8] +exclude = .git,.tox,__pycache__,pyHS100/tests/fakes.py