diff --git a/plexapi/utils.py b/plexapi/utils.py index ad28a5cb..467ccf05 100644 --- a/plexapi/utils.py +++ b/plexapi/utils.py @@ -144,22 +144,21 @@ def cast(func, value): func (func): Callback function to used cast to type (int, bool, float). value (any): value to be cast and returned. """ - if value is not None: - if func == bool: - if value in (1, True, "1", "true"): - return True - elif value in (0, False, "0", "false"): - return False - else: - raise ValueError(value) + if value is None: + return value + if func == bool: + if value in (1, True, "1", "true"): + return True + if value in (0, False, "0", "false"): + return False + raise ValueError(value) - elif func in (int, float): - try: - return func(value) - except ValueError: - return float('nan') - return func(value) - return value + if func in (int, float): + try: + return func(value) + except ValueError: + return float('nan') + return func(value) def joinArgs(args):