Skip to content

Commit 90db72c

Browse files
committed
apply requested changes regarding formatting and code refactoring
1 parent d940c27 commit 90db72c

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

plexapi/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class PlexObject:
5454
initpath (str): Relative path requested when retrieving specified `data` (optional).
5555
parent (:class:`~plexapi.base.PlexObject`): The parent object that this object is built from (optional).
5656
"""
57-
TAG: Optional[str] = None # xml element tag
58-
TYPE: Optional[str] = None # xml element type
57+
TAG: Optional[str] = None # xml element tag
58+
TYPE: Optional[str] = None # xml element type
5959
key: Optional[str] = None # plex relative url
6060
_INCLUDES = {
6161
'checkFiles': 1,

plexapi/utils.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,22 @@ def cast(
171171
func (func): Callback function to used cast to type (int, bool, float).
172172
value (any): value to be cast and returned.
173173
"""
174-
if value is None:
175-
return value
176-
if func == bool:
177-
if value in (1, True, "1", "true"):
178-
return True
179-
if value in (0, False, "0", "false"):
180-
return False
181-
raise ValueError(value)
182-
183-
if func in (int, float):
184-
try:
185-
return func(value)
186-
except ValueError:
187-
return float('nan')
188-
return func(value)
174+
if value is not None:
175+
if func == bool:
176+
if value in (1, True, "1", "true"):
177+
return True
178+
elif value in (0, False, "0", "false"):
179+
return False
180+
else:
181+
raise ValueError(value)
182+
183+
elif func in (int, float):
184+
try:
185+
return func(value)
186+
except ValueError:
187+
return float('nan')
188+
return func(value)
189+
return value
189190

190191

191192
def joinArgs(args):

0 commit comments

Comments
 (0)