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

Simplify omit http_client in DeviceConfig serialization (#1292) · rytilahti/python-kasa@cd26ea1 · GitHub

Repository navigation

Commit cd26ea1

Browse files
authored andcommitted
Simplify omit http_client in DeviceConfig serialization (python-kasa#1292)
Related explanation: Fatal1ty/mashumaro#264
1 parent d65ec91 commit cd26ea1

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

‎kasa/deviceconfig.py‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@
3333
import logging
3434
from dataclasses import dataclass, field, replace
3535
from enum import Enum
36-
from typing import TYPE_CHECKING, Any, Self, TypedDict
36+
from typing import TYPE_CHECKING, TypedDict
3737

3838
from aiohttp import ClientSession
39-
from mashumaro import field_options
39+
from mashumaro import field_options, pass_through
4040
from mashumaro.config import BaseConfig
41-
from mashumaro.types import SerializationStrategy
4241

4342
from .credentials import Credentials
4443
from .exceptions import KasaException
@@ -122,14 +121,6 @@ def from_values(
122121
) from ex
123122

124123

125-
class _DoNotSerialize(SerializationStrategy):
126-
def serialize(self, value: Any) -> None:
127-
return None # pragma: no cover
128-
129-
def deserialize(self, value: Any) -> None:
130-
return None # pragma: no cover
131-
132-
133124
@dataclass
134125
class DeviceConfig(_DeviceConfigBaseMixin):
135126
"""Class to represent paramaters that determine how to connect to devices."""
@@ -163,7 +154,7 @@ class DeviceConfig(_DeviceConfigBaseMixin):
163154
http_client: ClientSession | None = field(
164155
default=None,
165156
compare=False,
166-
metadata=field_options(serialization_strategy=_DoNotSerialize()),
157+
metadata=field_options(serialize="omit", deserialize=pass_through),
167158
)
168159

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

177-
def __pre_serialize__(self) -> Self:
178-
return replace(self, http_client=None)
179-
180168
def to_dict_control_credentials(
181169
self,
182170
*,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL