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
/build

View File

@ -1,4 +1,20 @@
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
rev: stable
hooks:

View File

@ -699,5 +699,3 @@ Other changes:
- Create pyHS100.py. [GadgetReactor]
- Initial commit. [GadgetReactor]

View File

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

View File

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

View File

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