mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Drop python3.8 support (#992)
Drop support for soon-to-be eol'd python 3.8. This will allow some minor cleanups & makes it easier to add support for timezones. Related to https://github.com/python-kasa/python-kasa/issues/980#issuecomment-2170889543
This commit is contained in:
@@ -10,8 +10,9 @@ import base64
|
||||
import hashlib
|
||||
import logging
|
||||
import time
|
||||
from collections.abc import AsyncGenerator
|
||||
from enum import Enum, auto
|
||||
from typing import TYPE_CHECKING, Any, AsyncGenerator, Dict, cast
|
||||
from typing import TYPE_CHECKING, Any, Dict, cast
|
||||
|
||||
from cryptography.hazmat.primitives import padding, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import padding as asymmetric_padding
|
||||
|
@@ -106,9 +106,10 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Any, Mapping, Sequence
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from warnings import warn
|
||||
|
||||
from typing_extensions import TypeAlias
|
||||
|
@@ -86,7 +86,8 @@ import binascii
|
||||
import ipaddress
|
||||
import logging
|
||||
import socket
|
||||
from typing import Awaitable, Callable, Dict, Optional, Type, cast
|
||||
from collections.abc import Awaitable
|
||||
from typing import Callable, Dict, Optional, Type, cast
|
||||
|
||||
# When support for cpython older than 3.11 is dropped
|
||||
# async_timeout can be replaced with asyncio.timeout
|
||||
|
@@ -71,7 +71,7 @@ Light preset 1
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from ..feature import Feature
|
||||
from ..module import Module
|
||||
|
@@ -18,8 +18,9 @@ import collections.abc
|
||||
import functools
|
||||
import inspect
|
||||
import logging
|
||||
from collections.abc import Mapping, Sequence
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import TYPE_CHECKING, Any, Mapping, Sequence, cast
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
from ..device import Device, WifiNetwork
|
||||
from ..deviceconfig import DeviceConfig
|
||||
|
@@ -2,8 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import asdict
|
||||
from typing import TYPE_CHECKING, Optional, Sequence
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic.v1 import BaseModel, Field
|
||||
|
||||
|
@@ -4,8 +4,9 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from collections.abc import Coroutine
|
||||
from datetime import date
|
||||
from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional
|
||||
|
||||
# When support for cpython older than 3.11 is dropped
|
||||
# async_timeout can be replaced with asyncio.timeout
|
||||
|
@@ -2,8 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import asdict
|
||||
from typing import TYPE_CHECKING, Sequence
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...interfaces import LightPreset as LightPresetInterface
|
||||
from ...interfaces import LightState
|
||||
|
@@ -4,8 +4,9 @@ from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import logging
|
||||
from collections.abc import Mapping, Sequence
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import TYPE_CHECKING, Any, Mapping, Sequence, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from ..aestransport import AesTransport
|
||||
from ..device import Device, WifiNetwork
|
||||
@@ -97,9 +98,7 @@ class SmartDevice(Device):
|
||||
@property
|
||||
def modules(self) -> ModuleMapping[SmartModule]:
|
||||
"""Return the device modules."""
|
||||
if TYPE_CHECKING: # Needed for python 3.8
|
||||
return cast(ModuleMapping[SmartModule], self._modules)
|
||||
return self._modules
|
||||
return cast(ModuleMapping[SmartModule], self._modules)
|
||||
|
||||
def _try_get_response(self, responses: dict, request: str, default=None) -> dict:
|
||||
response = responses.get(request)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import AsyncGenerator
|
||||
from collections.abc import AsyncGenerator
|
||||
|
||||
import pytest
|
||||
|
||||
|
@@ -91,9 +91,10 @@ async def test_state_info(dev):
|
||||
@pytest.mark.requires_dummy
|
||||
@device_iot
|
||||
async def test_invalid_connection(mocker, dev):
|
||||
with mocker.patch.object(
|
||||
FakeIotProtocol, "query", side_effect=KasaException
|
||||
), pytest.raises(KasaException):
|
||||
with (
|
||||
mocker.patch.object(FakeIotProtocol, "query", side_effect=KasaException),
|
||||
pytest.raises(KasaException),
|
||||
):
|
||||
await dev.update()
|
||||
|
||||
|
||||
|
@@ -38,9 +38,10 @@ async def test_update_no_device_info(dev: SmartDevice, mocker: MockerFixture):
|
||||
"get_device_time": {},
|
||||
}
|
||||
msg = f"get_device_info not found in {mock_response} for device 127.0.0.123"
|
||||
with mocker.patch.object(
|
||||
dev.protocol, "query", return_value=mock_response
|
||||
), pytest.raises(KasaException, match=msg):
|
||||
with (
|
||||
mocker.patch.object(dev.protocol, "query", return_value=mock_response),
|
||||
pytest.raises(KasaException, match=msg),
|
||||
):
|
||||
await dev.update()
|
||||
|
||||
|
||||
|
@@ -18,8 +18,8 @@ import errno
|
||||
import logging
|
||||
import socket
|
||||
import struct
|
||||
from collections.abc import Generator
|
||||
from pprint import pformat as pf
|
||||
from typing import Generator
|
||||
|
||||
# When support for cpython older than 3.11 is dropped
|
||||
# async_timeout can be replaced with asyncio.timeout
|
||||
|
Reference in New Issue
Block a user