Update poetry locks and pre-commit hooks (#837)

Also updates CI pypy versions to be 3.9 and 3.10 which are the currently
[supported
versions](https://www.pypy.org/posts/2024/01/pypy-v7315-release.html).
Otherwise latest cryptography doesn't ship with pypy3.8 wheels and is
unable to build on windows.

Also updates the `codecov-action` to v4 which fixed some intermittent
uploading errors.
This commit is contained in:
Steven B 2024-04-16 19:21:20 +01:00 committed by GitHub
parent 87fa39dd80
commit da441bc697
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
72 changed files with 904 additions and 846 deletions

View File

@ -61,7 +61,7 @@ jobs:
strategy: strategy:
matrix: matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8", "pypy-3.10"] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.9", "pypy-3.10"]
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
extras: [false, true] extras: [false, true]
exclude: exclude:
@ -70,7 +70,7 @@ jobs:
- os: windows-latest - os: windows-latest
extras: true extras: true
- os: ubuntu-latest - os: ubuntu-latest
python-version: "pypy-3.8" python-version: "pypy-3.9"
extras: true extras: true
- os: ubuntu-latest - os: ubuntu-latest
python-version: "pypy-3.10" python-version: "pypy-3.10"
@ -102,6 +102,6 @@ jobs:
run: | run: |
poetry run pytest --cov kasa --cov-report xml poetry run pytest --cov kasa --cov-report xml
- name: "Upload coverage to Codecov" - name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v3" uses: "codecov/codecov-action@v4"
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.6.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
@ -10,14 +10,14 @@ repos:
- id: check-ast - id: check-ast
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3 rev: v0.3.7
hooks: hooks:
- id: ruff - id: ruff
args: [--fix, --exit-non-zero-on-fix] args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format - id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0 rev: v1.9.0
hooks: hooks:
- id: mypy - id: mypy
additional_dependencies: [types-click] additional_dependencies: [types-click]

View File

@ -1,6 +1,5 @@
"""Test data for benchmarks.""" """Test data for benchmarks."""
import json import json
from .original import OriginalTPLinkSmartHomeProtocol from .original import OriginalTPLinkSmartHomeProtocol

View File

@ -1,4 +1,5 @@
"""Original implementation of the TP-Link Smart Home protocol.""" """Original implementation of the TP-Link Smart Home protocol."""
import struct import struct
from typing import Generator from typing import Generator

View File

@ -7,6 +7,7 @@ If you have new, yet unsupported device or a device with no devinfo file under
Executing this script will several modules and methods one by one, Executing this script will several modules and methods one by one,
and finally execute a query to query all of them at once. and finally execute a query to query all of them at once.
""" """
import base64 import base64
import collections.abc import collections.abc
import json import json

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
"""Script that checks supported devices and updates README.md and SUPPORTED.md.""" """Script that checks supported devices and updates README.md and SUPPORTED.md."""
import json import json
import os import os
import sys import sys

View File

@ -1,4 +1,5 @@
"""Script for testing update performance on devices.""" """Script for testing update performance on devices."""
import asyncio import asyncio
import time import time

View File

@ -11,6 +11,7 @@ For device type specific actions `SmartBulb`, `SmartPlug`, or `SmartStrip`
Module-specific errors are raised as `KasaException` and are expected Module-specific errors are raised as `KasaException` and are expected
to be handled by the user of the library. to be handled by the user of the library.
""" """
from importlib.metadata import version from importlib.metadata import version
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from warnings import warn from warnings import warn

View File

@ -3,6 +3,7 @@
Based on the work of https://github.com/petretiandrea/plugp100 Based on the work of https://github.com/petretiandrea/plugp100
under compatible GNU GPL3 license. under compatible GNU GPL3 license.
""" """
import asyncio import asyncio
import base64 import base64
import hashlib import hashlib

View File

@ -1,4 +1,5 @@
"""Module for Device base class.""" """Module for Device base class."""
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Dict, List, NamedTuple, Optional from typing import Dict, List, NamedTuple, Optional

View File

@ -1,4 +1,5 @@
"""python-kasa cli tool.""" """python-kasa cli tool."""
import ast import ast
import asyncio import asyncio
import json import json

View File

@ -1,4 +1,5 @@
"""Module for Device base class.""" """Module for Device base class."""
import logging import logging
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1,4 +1,5 @@
"""Device creation via DeviceConfig.""" """Device creation via DeviceConfig."""
import logging import logging
import time import time
from typing import Any, Dict, Optional, Tuple, Type from typing import Any, Dict, Optional, Tuple, Type

View File

@ -1,6 +1,5 @@
"""TP-Link device types.""" """TP-Link device types."""
from enum import Enum from enum import Enum

View File

@ -1,4 +1,5 @@
"""Module for holding connection parameters.""" """Module for holding connection parameters."""
import logging import logging
from dataclasses import asdict, dataclass, field, fields, is_dataclass from dataclasses import asdict, dataclass, field, fields, is_dataclass
from enum import Enum from enum import Enum

View File

@ -1,4 +1,5 @@
"""Discovery module for TP-Link Smart Home devices.""" """Discovery module for TP-Link Smart Home devices."""
import asyncio import asyncio
import binascii import binascii
import ipaddress import ipaddress

View File

@ -1,4 +1,5 @@
"""Module for emeter container.""" """Module for emeter container."""
import logging import logging
from typing import Optional from typing import Optional

View File

@ -1,4 +1,5 @@
"""python-kasa exceptions.""" """python-kasa exceptions."""
from asyncio import TimeoutError as _asyncioTimeoutError from asyncio import TimeoutError as _asyncioTimeoutError
from enum import IntEnum from enum import IntEnum
from typing import Any, Optional from typing import Any, Optional

View File

@ -1,4 +1,5 @@
"""Generic interface for defining device features.""" """Generic interface for defining device features."""
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, auto from enum import Enum, auto
from typing import TYPE_CHECKING, Any, Callable, Optional, Union from typing import TYPE_CHECKING, Any, Callable, Optional, Union

View File

@ -1,4 +1,5 @@
"""Module for HttpClientSession class.""" """Module for HttpClientSession class."""
import asyncio import asyncio
import logging import logging
from typing import Any, Dict, Optional, Tuple, Union from typing import Any, Dict, Optional, Tuple, Union

View File

@ -1,4 +1,5 @@
"""Package for supporting legacy kasa devices.""" """Package for supporting legacy kasa devices."""
from .iotbulb import IotBulb from .iotbulb import IotBulb
from .iotdevice import IotDevice from .iotdevice import IotDevice
from .iotdimmer import IotDimmer from .iotdimmer import IotDimmer

View File

@ -1,4 +1,5 @@
"""Module for bulbs (LB*, KL*, KB*).""" """Module for bulbs (LB*, KL*, KB*)."""
import logging import logging
import re import re
from enum import Enum from enum import Enum
@ -233,7 +234,6 @@ class IotBulb(IotDevice, Bulb):
) )
) )
@property # type: ignore @property # type: ignore
@requires_update @requires_update
def is_color(self) -> bool: def is_color(self) -> bool:

View File

@ -11,6 +11,7 @@ Stroetmann which is licensed under the Apache License, Version 2.0.
You may obtain a copy of the license at You may obtain a copy of the license at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
""" """
import collections.abc import collections.abc
import functools import functools
import inspect import inspect

View File

@ -1,4 +1,5 @@
"""Module for dimmers (currently only HS220).""" """Module for dimmers (currently only HS220)."""
from enum import Enum from enum import Enum
from typing import Any, Dict, Optional from typing import Any, Dict, Optional

View File

@ -1,4 +1,5 @@
"""Module for light strips (KL430).""" """Module for light strips (KL430)."""
from typing import Dict, List, Optional from typing import Dict, List, Optional
from ..device_type import DeviceType from ..device_type import DeviceType

View File

@ -1,4 +1,5 @@
"""Base class for IOT module implementations.""" """Base class for IOT module implementations."""
import collections import collections
import logging import logging

View File

@ -1,4 +1,5 @@
"""Module for smart plugs (HS100, HS110, ..).""" """Module for smart plugs (HS100, HS110, ..)."""
import logging import logging
from typing import Optional from typing import Optional

View File

@ -1,4 +1,5 @@
"""Module for multi-socket devices (HS300, HS107, KP303, ..).""" """Module for multi-socket devices (HS300, HS107, KP303, ..)."""
import logging import logging
from collections import defaultdict from collections import defaultdict
from datetime import datetime, timedelta from datetime import datetime, timedelta

View File

@ -1,4 +1,5 @@
"""Module for individual feature modules.""" """Module for individual feature modules."""
from .ambientlight import AmbientLight from .ambientlight import AmbientLight
from .antitheft import Antitheft from .antitheft import Antitheft
from .cloud import Cloud from .cloud import Cloud

View File

@ -1,4 +1,5 @@
"""Implementation of the ambient light (LAS) module found in some dimmers.""" """Implementation of the ambient light (LAS) module found in some dimmers."""
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType
from ..iotmodule import IotModule, merge from ..iotmodule import IotModule, merge

View File

@ -1,4 +1,5 @@
"""Implementation of the antitheft module.""" """Implementation of the antitheft module."""
from .rulemodule import RuleModule from .rulemodule import RuleModule

View File

@ -1,4 +1,5 @@
"""Cloud module implementation.""" """Cloud module implementation."""
try: try:
from pydantic.v1 import BaseModel from pydantic.v1 import BaseModel
except ImportError: except ImportError:

View File

@ -1,4 +1,5 @@
"""Implementation for the countdown timer.""" """Implementation for the countdown timer."""
from .rulemodule import RuleModule from .rulemodule import RuleModule

View File

@ -1,4 +1,5 @@
"""Implementation of the emeter module.""" """Implementation of the emeter module."""
from datetime import datetime from datetime import datetime
from typing import Dict, List, Optional, Union from typing import Dict, List, Optional, Union

View File

@ -1,4 +1,5 @@
"""Implementation of the motion detection (PIR) module found in some dimmers.""" """Implementation of the motion detection (PIR) module found in some dimmers."""
from enum import Enum from enum import Enum
from typing import Optional from typing import Optional

View File

@ -1,4 +1,5 @@
"""Base implementation for all rule-based modules.""" """Base implementation for all rule-based modules."""
import logging import logging
from enum import Enum from enum import Enum
from typing import Dict, List, Optional from typing import Dict, List, Optional

View File

@ -1,4 +1,5 @@
"""Schedule module implementation.""" """Schedule module implementation."""
from .rulemodule import RuleModule from .rulemodule import RuleModule

View File

@ -1,4 +1,5 @@
"""Provides the current time and timezone information.""" """Provides the current time and timezone information."""
from datetime import datetime from datetime import datetime
from ...exceptions import KasaException from ...exceptions import KasaException

View File

@ -1,4 +1,5 @@
"""Implementation of the usage interface.""" """Implementation of the usage interface."""
from datetime import datetime from datetime import datetime
from typing import Dict from typing import Dict

View File

@ -1,4 +1,5 @@
"""Module for the IOT legacy IOT KASA protocol.""" """Module for the IOT legacy IOT KASA protocol."""
import asyncio import asyncio
import logging import logging
from typing import Dict, Optional, Union from typing import Dict, Optional, Union

View File

@ -1,4 +1,5 @@
"""Base class for all module implementations.""" """Base class for all module implementations."""
import logging import logging
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Dict from typing import Dict

View File

@ -1,4 +1,5 @@
"""Module for a TAPO Plug.""" """Module for a TAPO Plug."""
import logging import logging
from abc import ABC from abc import ABC

View File

@ -9,6 +9,7 @@ https://github.com/softScheck/tplink-smartplug/
which are licensed under the Apache License, Version 2.0 which are licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
""" """
import base64 import base64
import errno import errno
import hashlib import hashlib

View File

@ -1,4 +1,5 @@
"""Package for supporting tapo-branded and newer kasa devices.""" """Package for supporting tapo-branded and newer kasa devices."""
from .smartbulb import SmartBulb from .smartbulb import SmartBulb
from .smartchilddevice import SmartChildDevice from .smartchilddevice import SmartChildDevice
from .smartdevice import SmartDevice from .smartdevice import SmartDevice

View File

@ -1,4 +1,5 @@
"""Modules for SMART devices.""" """Modules for SMART devices."""
from .alarmmodule import AlarmModule from .alarmmodule import AlarmModule
from .autooffmodule import AutoOffModule from .autooffmodule import AutoOffModule
from .battery import BatterySensor from .battery import BatterySensor

View File

@ -1,4 +1,5 @@
"""Implementation of alarm module.""" """Implementation of alarm module."""
from typing import TYPE_CHECKING, Dict, List, Optional from typing import TYPE_CHECKING, Dict, List, Optional
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Implementation of auto off module.""" """Implementation of auto off module."""
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Dict, Optional from typing import TYPE_CHECKING, Dict, Optional

View File

@ -1,4 +1,5 @@
"""Implementation of battery module.""" """Implementation of battery module."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Implementation of brightness module.""" """Implementation of brightness module."""
from typing import TYPE_CHECKING, Dict from typing import TYPE_CHECKING, Dict
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Implementation of cloud module.""" """Implementation of cloud module."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Implementation of color temp module.""" """Implementation of color temp module."""
from typing import TYPE_CHECKING, Dict from typing import TYPE_CHECKING, Dict
from ...bulb import ColorTempRange from ...bulb import ColorTempRange

View File

@ -1,4 +1,5 @@
"""Implementation of device module.""" """Implementation of device module."""
from typing import Dict from typing import Dict
from ..smartmodule import SmartModule from ..smartmodule import SmartModule

View File

@ -1,4 +1,5 @@
"""Implementation of energy monitoring module.""" """Implementation of energy monitoring module."""
from typing import TYPE_CHECKING, Dict, Optional from typing import TYPE_CHECKING, Dict, Optional
from ...emeterstatus import EmeterStatus from ...emeterstatus import EmeterStatus

View File

@ -1,4 +1,5 @@
"""Implementation of firmware module.""" """Implementation of firmware module."""
from typing import TYPE_CHECKING, Dict, Optional from typing import TYPE_CHECKING, Dict, Optional
from ...exceptions import SmartErrorCode from ...exceptions import SmartErrorCode

View File

@ -1,4 +1,5 @@
"""Implementation of humidity module.""" """Implementation of humidity module."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Module for led controls.""" """Module for led controls."""
from typing import TYPE_CHECKING, Dict from typing import TYPE_CHECKING, Dict
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Module for smooth light transitions.""" """Module for smooth light transitions."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ...exceptions import KasaException from ...exceptions import KasaException

View File

@ -1,4 +1,5 @@
"""Implementation of report module.""" """Implementation of report module."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from ...feature import Feature from ...feature import Feature

View File

@ -1,4 +1,5 @@
"""Implementation of temperature module.""" """Implementation of temperature module."""
from typing import TYPE_CHECKING, Literal from typing import TYPE_CHECKING, Literal
from ...feature import Feature, FeatureType from ...feature import Feature, FeatureType

View File

@ -1,4 +1,5 @@
"""Implementation of time module.""" """Implementation of time module."""
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from time import mktime from time import mktime
from typing import TYPE_CHECKING, cast from typing import TYPE_CHECKING, cast

View File

@ -1,4 +1,5 @@
"""Module for tapo-branded smart bulbs (L5**).""" """Module for tapo-branded smart bulbs (L5**)."""
from typing import Dict, List, Optional from typing import Dict, List, Optional
from ..bulb import Bulb from ..bulb import Bulb

View File

@ -1,4 +1,5 @@
"""Child device implementation.""" """Child device implementation."""
import logging import logging
from typing import Optional from typing import Optional

View File

@ -1,4 +1,5 @@
"""Module for a SMART device.""" """Module for a SMART device."""
import base64 import base64
import logging import logging
from datetime import datetime, timedelta from datetime import datetime, timedelta

View File

@ -1,4 +1,5 @@
"""Base implementation for SMART modules.""" """Base implementation for SMART modules."""
import logging import logging
from typing import TYPE_CHECKING, Dict, Type from typing import TYPE_CHECKING, Dict, Type

View File

@ -302,9 +302,9 @@ class FakeIotProtocol(IotProtocol):
def set_preferred_state(self, new_state, *args): def set_preferred_state(self, new_state, *args):
"""Implement set_preferred_state.""" """Implement set_preferred_state."""
self.proto["system"]["get_sysinfo"]["preferred_state"][ self.proto["system"]["get_sysinfo"]["preferred_state"][new_state["index"]] = (
new_state["index"] new_state
] = new_state )
def light_state(self, x, *args): def light_state(self, x, *args):
light_state = self.proto["system"]["get_sysinfo"]["light_state"] light_state = self.proto["system"]["get_sysinfo"]["light_state"]

View File

@ -15,7 +15,7 @@ class FixtureInfo(NamedTuple):
data: Dict data: Dict
FixtureInfo.__hash__ = lambda x: hash((x.name, x.protocol)) # type: ignore[attr-defined, method-assign] FixtureInfo.__hash__ = lambda self: hash((self.name, self.protocol)) # type: ignore[attr-defined, method-assign]
FixtureInfo.__eq__ = lambda x, y: hash(x) == hash(y) # type: ignore[method-assign] FixtureInfo.__eq__ = lambda x, y: hash(x) == hash(y) # type: ignore[method-assign]

View File

@ -1,4 +1,5 @@
"""Tests for all devices.""" """Tests for all devices."""
import importlib import importlib
import inspect import inspect
import pkgutil import pkgutil

View File

@ -1,4 +1,5 @@
"""Module for common iotdevice tests.""" """Module for common iotdevice tests."""
import re import re
from datetime import datetime from datetime import datetime

View File

@ -1,4 +1,5 @@
"""Tests for SMART devices.""" """Tests for SMART devices."""
import logging import logging
from typing import Any, Dict from typing import Any, Dict

View File

@ -9,6 +9,7 @@ https://github.com/softScheck/tplink-smartplug/
which are licensed under the Apache License, Version 2.0 which are licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
""" """
import asyncio import asyncio
import contextlib import contextlib
import errno import errno

1657
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -101,6 +101,8 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff] [tool.ruff]
target-version = "py38" target-version = "py38"
[tool.ruff.lint]
select = [ select = [
"E", # pycodestyle "E", # pycodestyle
"D", # pydocstyle "D", # pydocstyle
@ -116,10 +118,10 @@ ignore = [
"D107", # Missing docstring in `__init__` "D107", # Missing docstring in `__init__`
] ]
[tool.ruff.pydocstyle] [tool.ruff.lint.pydocstyle]
convention = "pep257" convention = "pep257"
[tool.ruff.per-file-ignores] [tool.ruff.lint.per-file-ignores]
"kasa/tests/*.py" = [ "kasa/tests/*.py" = [
"D100", "D100",
"D101", "D101",