Convert to use poetry & pyproject.toml for dep & build management (#54)

* Convert to use poetry and pyproject.toml, update README

* add some resources for contributors

* minor adjustments

* ci: separate tests from linting, run using poetry

* add pytest-mock to dev requirements

* combine running tests and reporting to codecov

* generate both xml and html coverage reports

* add codecov to dev dependencies
This commit is contained in:
Teemu R
2020-05-12 12:11:47 +02:00
committed by GitHub
parent c6d76836d7
commit ed57563e8b
19 changed files with 296 additions and 312 deletions

View File

@@ -11,6 +11,7 @@ For device type specific actions `SmartBulb`, `SmartPlug`, or `SmartStrip`
Module-specific errors are raised as `SmartDeviceException` and are expected
to be handled by the user of the library.
"""
from importlib_metadata import version # type: ignore
from kasa.discover import Discover
from kasa.protocol import TPLinkSmartHomeProtocol
from kasa.smartbulb import SmartBulb
@@ -19,6 +20,9 @@ from kasa.smartdimmer import SmartDimmer
from kasa.smartplug import SmartPlug
from kasa.smartstrip import SmartStrip
__version__ = version("python-kasa")
__all__ = [
"Discover",
"TPLinkSmartHomeProtocol",

View File

@@ -7,6 +7,7 @@ from pprint import pformat as pf
from typing import cast
import asyncclick as click
from kasa import Discover, SmartBulb, SmartDevice, SmartPlug, SmartStrip
click.anyio_backend = "asyncio"

View File

@@ -23,7 +23,7 @@ TPLINK_KELVIN = {
class SmartBulb(SmartDevice):
"""Representation of a TP-Link Smart Bulb.
Usage example when used as library:
Usage example:
```python
p = SmartBulb("192.168.1.105")
await p.update()
@@ -33,6 +33,7 @@ class SmartBulb(SmartDevice):
# change state of bulb
await p.turn_on()
assert p.is_on
await p.turn_off()
# query and print current state of plug
@@ -40,12 +41,11 @@ class SmartBulb(SmartDevice):
# check whether the bulb supports color changes
if p.is_color:
# set the color to an HSV tuple
await p.set_hsv(180, 100, 100)
# get the current HSV value
print(p.hsv)
print("we got color!")
# set the color to an HSV tuple
await p.set_hsv(180, 100, 100)
# get the current HSV value
print(p.hsv)
# check whether the bulb supports setting color temperature
if p.is_variable_color_temp:
@@ -57,12 +57,11 @@ class SmartBulb(SmartDevice):
# check whether the bulb is dimmable
if p.is_dimmable:
# set the bulb to 50% brightness
await p.set_brightness(50)
# set the bulb to 50% brightness
await p.set_brightness(50)
# check the current brightness
print(p.brightness)
# check the current brightness
print(p.brightness)
```
Errors reported by the device are raised as SmartDeviceExceptions,

View File

@@ -10,7 +10,7 @@ _LOGGER = logging.getLogger(__name__)
class SmartPlug(SmartDevice):
"""Representation of a TP-Link Smart Switch.
Usage example when used a a synchronous library:
Usage example:
```python
p = SmartPlug("192.168.1.105")
@@ -19,9 +19,10 @@ class SmartPlug(SmartDevice):
# change state of plug
await p.turn_on()
assert p.is_on is True
await p.turn_off()
# query and print current state of plug
# print current state of plug
print(p.state_information)
```

View File

@@ -4,7 +4,7 @@ import json
import os
from os.path import basename
import pytest
import pytest # type: ignore # see https://github.com/pytest-dev/pytest/issues/3342
from kasa import Discover, SmartBulb, SmartDimmer, SmartPlug, SmartStrip

View File

@@ -1,7 +1,16 @@
import logging
import re
from voluptuous import REMOVE_EXTRA, All, Any, Coerce, Invalid, Optional, Range, Schema
from voluptuous import ( # type: ignore
REMOVE_EXTRA,
All,
Any,
Coerce,
Invalid,
Optional,
Range,
Schema,
)
from ..protocol import TPLinkSmartHomeProtocol

View File

@@ -1,6 +1,6 @@
import pytest
from asyncclick.testing import CliRunner
from kasa import SmartDevice
from kasa.cli import alias, brightness, emeter, raw_command, state, sysinfo

View File

@@ -2,7 +2,7 @@ import asyncio
from datetime import datetime
from unittest.mock import patch
import pytest
import pytest # type: ignore # https://github.com/pytest-dev/pytest/issues/3342
from kasa import DeviceType, SmartDeviceException, SmartStrip

View File

@@ -1,2 +0,0 @@
# flake8: noqa
__version__ = "0.4.0.dev0"