run pre-commit run --all

This commit is contained in:
Bas Nijholt 2019-12-12 10:41:52 +01:00
parent 338e6ce743
commit 122cd4c19f
19 changed files with 54 additions and 39 deletions

2
.gitignore vendored
View File

@ -24,5 +24,3 @@ venv
.venv .venv
/build /build

View File

@ -1,4 +1,20 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-yaml
- id: debug-statements
- id: check-ast
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.2
hooks:
- id: pyupgrade
args: ['--py36-plus']
- repo: https://github.com/python/black - repo: https://github.com/python/black
rev: stable rev: stable
hooks: hooks:

View File

@ -96,11 +96,11 @@ There are two notable changes (and other small fixes) in this minor release than
0.3.3 (2018-09-06) 0.3.3 (2018-09-06)
------------------ ------------------
This release contains a breaking change for hsv setter, which is changed to accept This release contains a breaking change for hsv setter, which is changed to accept
the new brightness value in percentage instead of an integer between 1 and 255. the new brightness value in percentage instead of an integer between 1 and 255.
The alias support has been extended to allow changing the alias, as well as accessing The alias support has been extended to allow changing the alias, as well as accessing
the device using it (without specifying an IP address or a hostname), which can be the device using it (without specifying an IP address or a hostname), which can be
useful in some setups. Furthermore utf8-encoded aliases are now handled correctly. useful in some setups. Furthermore utf8-encoded aliases are now handled correctly.
- Fix bug that changed brightness at each HSV update (#124) [Sebastian Templ] - Fix bug that changed brightness at each HSV update (#124) [Sebastian Templ]
@ -126,7 +126,7 @@ useful in some setups. Furthermore utf8-encoded aliases are now handled correctl
within their valid ranges (0..255, 0..100, 0..100) and raise within their valid ranges (0..255, 0..100, 0..100) and raise
SmartDeviceException if they are not SmartDeviceException if they are not
- add test function for the hsv setter - add test function for the hsv setter
- Allow using alias instead of IP address or hostname (#127) [kwazel] - Allow using alias instead of IP address or hostname (#127) [kwazel]
* Added option to control devices by device name * Added option to control devices by device name
@ -140,7 +140,7 @@ useful in some setups. Furthermore utf8-encoded aliases are now handled correctl
* processed review comments * processed review comments
* Return when no device with alias has been found * Return when no device with alias has been found
- Add 'alias' command for querying and setting the alias (#126) [Teemu R] - Add 'alias' command for querying and setting the alias (#126) [Teemu R]
* add 'alias' command for querying and setting the alias * add 'alias' command for querying and setting the alias
@ -152,7 +152,7 @@ useful in some setups. Furthermore utf8-encoded aliases are now handled correctl
* readd py33, remove it from travis as it seems to be a travis limitation only * readd py33, remove it from travis as it seems to be a travis limitation only
* use xenial dist for travis, regular does not support py37.. * use xenial dist for travis, regular does not support py37..
- Support Unicode strings in encrypt/decrypt (#125) [Anders Melchiorsen] - Support Unicode strings in encrypt/decrypt (#125) [Anders Melchiorsen]
@ -193,18 +193,18 @@ Breaking changes:
* Adds a new 'kwh' parameter for those calls, which defaults to True * Adds a new 'kwh' parameter for those calls, which defaults to True
* This changes the behavior of bulbs emeter reporting, use False if you prefer the preciser values * This changes the behavior of bulbs emeter reporting, use False if you prefer the preciser values
- Update pypi description (#102) [Teemu R] - Update pypi description (#102) [Teemu R]
* update pypi description * update pypi description
* add wall switches * add wall switches
- Update smartplug.py to support dimming in HS220 (#115) [JsChiSurf] - Update smartplug.py to support dimming in HS220 (#115) [JsChiSurf]
* Update smartplug.py to support dimming in HS220 * Update smartplug.py to support dimming in HS220
Switch functions essentially as a "plug" with the addition to support for dimming, for which can be test for by verifying existence of Switch functions essentially as a "plug" with the addition to support for dimming, for which can be test for by verifying existence of
'brightness' array value. 'brightness' array value.
* Attempt at updates to pass validator * Attempt at updates to pass validator
@ -213,7 +213,7 @@ Breaking changes:
* Add more detail to comment blocks * Add more detail to comment blocks
Make clear in requests for current brightness level the expected return values, and note that light will turn on when setting a brightness Make clear in requests for current brightness level the expected return values, and note that light will turn on when setting a brightness
level, if not already on. This makes clear that a state change request (turn_on) does NOT have to be made first when setting brightness. level, if not already on. This makes clear that a state change request (turn_on) does NOT have to be made first when setting brightness.
* Update smartplug.py * Update smartplug.py
@ -221,22 +221,22 @@ level, if not already on. This makes clear that a state change request (turn_on
* Update smartplug.py * Update smartplug.py
Fixes #114 Fixes #114
- Add python_requires for >= 3.4. [Teemu Rytilahti] - Add python_requires for >= 3.4. [Teemu Rytilahti]
- Add hs210. [Teemu R] - Add hs210. [Teemu R]
Based on user report: https://community.home-assistant.io/t/tp-link-hs210-3-way-kit/39762/6 Based on user report: https://community.home-assistant.io/t/tp-link-hs210-3-way-kit/39762/6
- Add support for DNS host names (#104) [K Henriksson] - Add support for DNS host names (#104) [K Henriksson]
- Use direct device type discovery for devices (#106) [K Henriksson] - Use direct device type discovery for devices (#106) [K Henriksson]
This is more efficient than enumerating all devices and checking the IP. This is more efficient than enumerating all devices and checking the IP.
- Cli: add 'time' command to get the current time from the device. - Cli: add 'time' command to get the current time from the device.
[Teemu Rytilahti] [Teemu Rytilahti]
- Created a docker file to aid dev setup (#99) [TheSmokingGnu] - Created a docker file to aid dev setup (#99) [TheSmokingGnu]
* created a docker file to aid dev setup * created a docker file to aid dev setup
@ -361,31 +361,31 @@ Other changes:
* Check for mic_mac on mac, based on work by kdschloesser on issue #59 * Check for mic_mac on mac, based on work by kdschloesser on issue #59
* make hound happy, __init__ on SmartDevice cannot error out so removing 'raises' documentation * make hound happy, __init__ on SmartDevice cannot error out so removing 'raises' documentation
- Add LB110 sysinfo (#75) [Sean Gollschewsky] - Add LB110 sysinfo (#75) [Sean Gollschewsky]
* Add LB110 sysinfo * Add LB110 sysinfo
* Linting. * Linting.
- Add @pass_dev to hsv, adjust ranges (#70) [Teemu R] - Add @pass_dev to hsv, adjust ranges (#70) [Teemu R]
* add @pass_dev to hsv command, it was always broken * add @pass_dev to hsv command, it was always broken
* Hue goes up to 360, saturation and value are up to 100(%) * Hue goes up to 360, saturation and value are up to 100(%)
- Extract shared types (exceptions, enums), add module level doc, rename exception to be generic. [Teemu Rytilahti] - Extract shared types (exceptions, enums), add module level doc, rename exception to be generic. [Teemu Rytilahti]
- Add check to ensure devices with lat/lon with `_i` suffix are supported (#54) (#56) [Matt LeBrun] - Add check to ensure devices with lat/lon with `_i` suffix are supported (#54) (#56) [Matt LeBrun]
* Add check to ensure devices with lat/lon with `_i` suffix are supported (#54) * Add check to ensure devices with lat/lon with `_i` suffix are supported (#54)
* Add .gitignore for posterity * Add .gitignore for posterity
- Generalize smartdevice class and add bulb support for the cli tool (#50) [Teemu R] - Generalize smartdevice class and add bulb support for the cli tool (#50) [Teemu R]
Fixes #48 and #51. The basic functionality should work on all types of supported devices, for bulb specific commands it is currently necessary to specify ```--bulb```. Fixes #48 and #51. The basic functionality should work on all types of supported devices, for bulb specific commands it is currently necessary to specify ```--bulb```.
- Refactor and drop py2 support (#49) [Teemu R] - Refactor and drop py2 support (#49) [Teemu R]
* move is_off property to SmartDevice, implement is_on for bulb and use it * move is_off property to SmartDevice, implement is_on for bulb and use it
@ -699,5 +699,3 @@ Other changes:
- Create pyHS100.py. [GadgetReactor] - Create pyHS100.py. [GadgetReactor]
- Initial commit. [GadgetReactor] - Initial commit. [GadgetReactor]

View File

@ -172,7 +172,7 @@ def sysinfo(dev):
def state(ctx, dev: SmartDevice): def state(ctx, dev: SmartDevice):
"""Print out device state and versions.""" """Print out device state and versions."""
dev.sync.update() dev.sync.update()
click.echo(click.style("== {} - {} ==".format(dev.alias, dev.model), bold=True)) click.echo(click.style(f"== {dev.alias} - {dev.model} ==", bold=True))
click.echo( click.echo(
click.style( click.style(
@ -199,8 +199,8 @@ def state(ctx, dev: SmartDevice):
click.echo("Time: {}".format(dev.sync.get_time())) click.echo("Time: {}".format(dev.sync.get_time()))
click.echo("Hardware: {}".format(dev.hw_info["hw_ver"])) click.echo("Hardware: {}".format(dev.hw_info["hw_ver"]))
click.echo("Software: {}".format(dev.hw_info["sw_ver"])) click.echo("Software: {}".format(dev.hw_info["sw_ver"]))
click.echo("MAC (rssi): {} ({})".format(dev.mac, dev.rssi)) click.echo(f"MAC (rssi): {dev.mac} ({dev.rssi})")
click.echo("Location: {}".format(dev.location)) click.echo(f"Location: {dev.location}")
ctx.invoke(emeter) ctx.invoke(emeter)

View File

@ -82,6 +82,7 @@ class EmeterStatus(dict):
def requires_update(f): def requires_update(f):
"""Indicate that `update` should be called before accessing this method.""" # noqa: D202 """Indicate that `update` should be called before accessing this method.""" # noqa: D202
if inspect.iscoroutinefunction(f): if inspect.iscoroutinefunction(f):
@functools.wraps(f) @functools.wraps(f)
async def wrapped(*args, **kwargs): async def wrapped(*args, **kwargs):
self = args[0] self = args[0]
@ -89,6 +90,7 @@ def requires_update(f):
return await f(*args, **kwargs) return await f(*args, **kwargs)
else: else:
@functools.wraps(f) @functools.wraps(f)
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
self = args[0] self = args[0]

View File

@ -44,4 +44,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -44,4 +44,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -46,4 +46,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -47,4 +47,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -47,4 +47,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -44,4 +44,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -72,4 +72,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -99,4 +99,4 @@
"updating": 0 "updating": 0
} }
} }
} }

View File

@ -90,4 +90,4 @@
"sw_ver": "1.8.6 Build 180809 Rel.091659" "sw_ver": "1.8.6 Build 180809 Rel.091659"
} }
} }
} }

View File

@ -100,4 +100,4 @@
"sw_ver": "1.4.3 Build 170504 Rel.144921" "sw_ver": "1.4.3 Build 170504 Rel.144921"
} }
} }
} }

View File

@ -100,4 +100,4 @@
"sw_ver": "1.1.0 Build 160630 Rel.085319" "sw_ver": "1.1.0 Build 160630 Rel.085319"
} }
} }
} }

View File

@ -101,4 +101,4 @@
"sw_ver": "1.6.0 Build 170703 Rel.141938" "sw_ver": "1.6.0 Build 170703 Rel.141938"
} }
} }
} }

View File

@ -604,5 +604,6 @@ def test_children_get_emeter_monthly(dev):
def test_representation(dev): def test_representation(dev):
import re import re
pattern = re.compile("<.* model .* at .* (.*), is_on: .* - dev specific: .*>") pattern = re.compile("<.* model .* at .* (.*), is_on: .* - dev specific: .*>")
assert pattern.match(str(dev)) assert pattern.match(str(dev))

View File

@ -15,7 +15,7 @@ deps=
voluptuous voluptuous
typing typing
deprecation deprecation
flake8 flake8
commands= commands=
py.test --cov --cov-config=tox.ini pyHS100 py.test --cov --cov-config=tox.ini pyHS100