Cleanup credentials handling (#605)

* credentials: don't allow none to simplify checks

* Implement __bool__ for credentials

* Cleanup klaptransport cred usage

* Cleanup deviceconfig and tapodevice

* fix linting

* Pass dummy credentials for tests

* Remove __bool__ dunder and add docs to credentials

* Check for cred noneness in tapodevice.update()
This commit is contained in:
Teemu R
2024-01-03 19:26:52 +01:00
committed by GitHub
parent 10fc2c3c54
commit 30c4e6a6a3
7 changed files with 29 additions and 17 deletions

View File

@@ -117,9 +117,7 @@ class DeviceConfig:
host: str
timeout: Optional[int] = DEFAULT_TIMEOUT
port_override: Optional[int] = None
credentials: Credentials = field(
default_factory=lambda: Credentials(username="", password="")
)
credentials: Credentials = field(default_factory=lambda: Credentials())
connection_type: ConnectionType = field(
default_factory=lambda: ConnectionType(
DeviceFamilyType.IotSmartPlugSwitch, EncryptType.Xor
@@ -132,7 +130,7 @@ class DeviceConfig:
def __post_init__(self):
if self.credentials is None:
self.credentials = Credentials(username="", password="")
self.credentials = Credentials()
if self.connection_type is None:
self.connection_type = ConnectionType(
DeviceFamilyType.IotSmartPlugSwitch, EncryptType.Xor