From 00a97b1d8b75729713e122101003cc7d6b3b0909 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:00:24 +0100 Subject: [PATCH] dict expansion for defaultkwarg --- obsstudio_sdk/baseclient.py | 6 ++++-- obsstudio_sdk/events.py | 29 +++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/obsstudio_sdk/baseclient.py b/obsstudio_sdk/baseclient.py index 50240e8..27a0c71 100644 --- a/obsstudio_sdk/baseclient.py +++ b/obsstudio_sdk/baseclient.py @@ -12,8 +12,10 @@ class ObsClient(object): DELAY = 0.001 def __init__(self, **kwargs): - defaultkwargs = {key: None for key in ["host", "port", "password"]} - defaultkwargs["subs"] = 0 + defaultkwargs = { + **{key: None for key in ["host", "port", "password"]}, + "subs": 0, + } kwargs = defaultkwargs | kwargs for attr, val in kwargs.items(): setattr(self, attr, val) diff --git a/obsstudio_sdk/events.py b/obsstudio_sdk/events.py index 8d62ab4..fa34a13 100644 --- a/obsstudio_sdk/events.py +++ b/obsstudio_sdk/events.py @@ -23,20 +23,21 @@ class EventClient(object): DELAY = 0.001 def __init__(self, **kwargs): - defaultkwargs = dict() - defaultkwargs["subs"] = ( - (1 << Subs.general) - | (1 << Subs.config) - | (1 << Subs.scenes) - | (1 << Subs.inputs) - | (1 << Subs.transitions) - | (1 << Subs.filters) - | (1 << Subs.outputs) - | (1 << Subs.sceneitems) - | (1 << Subs.mediainputs) - | (1 << Subs.vendors) - | (1 << Subs.ui) - ) + defaultkwargs = { + "subs": ( + (1 << Subs.general) + | (1 << Subs.config) + | (1 << Subs.scenes) + | (1 << Subs.inputs) + | (1 << Subs.transitions) + | (1 << Subs.filters) + | (1 << Subs.outputs) + | (1 << Subs.sceneitems) + | (1 << Subs.mediainputs) + | (1 << Subs.vendors) + | (1 << Subs.ui) + ) + } kwargs = defaultkwargs | kwargs self.base_client = ObsClient(**kwargs) self.base_client.authenticate()