From f0df2f4490dcf7a0bd40b68ce1333703ef0694f2 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 10 Sep 2022 20:37:41 +0100 Subject: [PATCH] PSSH: Merge some collapsible if statements --- pywidevine/pssh.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pywidevine/pssh.py b/pywidevine/pssh.py index 9e978cb..aac9961 100644 --- a/pywidevine/pssh.py +++ b/pywidevine/pssh.py @@ -108,13 +108,11 @@ class PSSH: flags: int = 0 ) -> PSSH: """Craft a new version 0 or 1 PSSH Box.""" - if key_ids is not None: - if not isinstance(key_ids, list): - raise TypeError(f"Expected key_ids to be a list not {key_ids!r}") + if key_ids is not None and not isinstance(key_ids, list): + raise TypeError(f"Expected key_ids to be a list not {key_ids!r}") - if init_data is not None: - if not isinstance(init_data, (WidevinePsshData, str, bytes)): - raise TypeError(f"Expected init_data to be a {WidevinePsshData}, base64, or bytes, not {init_data!r}") + if init_data is not None and not isinstance(init_data, (WidevinePsshData, str, bytes)): + raise TypeError(f"Expected init_data to be a {WidevinePsshData}, base64, or bytes, not {init_data!r}") if not isinstance(version, int): raise TypeError(f"Expected version to be an int not {version!r}")