FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Simplify omit http_client in DeviceConfig serialization by sdb9696 · Pull Request #1292 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 3 additions & 15 deletions kasa/deviceconfig.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
import logging
from dataclasses import dataclass, field, replace
from enum import Enum
from typing import TYPE_CHECKING, Any, Self, TypedDict
from typing import TYPE_CHECKING, TypedDict

from aiohttp import ClientSession
from mashumaro import field_options
from mashumaro import field_options, pass_through
from mashumaro.config import BaseConfig
from mashumaro.types import SerializationStrategy

from .credentials import Credentials
from .exceptions import KasaException
Expand Down Expand Up @@ -122,14 +121,6 @@ def from_values(
) from ex


class _DoNotSerialize(SerializationStrategy):
def serialize(self, value: Any) -> None:
return None # pragma: no cover

def deserialize(self, value: Any) -> None:
return None # pragma: no cover


@dataclass
class DeviceConfig(_DeviceConfigBaseMixin):
"""Class to represent paramaters that determine how to connect to devices."""
Expand Down Expand Up @@ -163,7 +154,7 @@ class DeviceConfig(_DeviceConfigBaseMixin):
http_client: ClientSession | None = field(
default=None,
compare=False,
metadata=field_options(serialization_strategy=_DoNotSerialize()),
metadata=field_options(serialize="omit", deserialize=pass_through),
)

aes_keys: KeyPairDict | None = None
Expand All @@ -174,9 +165,6 @@ def __post_init__(self) -> None:
DeviceFamily.IotSmartPlugSwitch, DeviceEncryptionType.Xor
)

def __pre_serialize__(self) -> Self:
return replace(self, http_client=None)

def to_dict_control_credentials(
self,
*,
Expand Down

Back | FazBrowse Home | New Git URL