Fix pylint 1.7.2 no-else-return issues (#8361)
* Fix pylint 1.7.2 no-else-return issues * Update tomato.py
This commit is contained in:
parent
5779d64e98
commit
46e030662d
111 changed files with 305 additions and 455 deletions
|
@ -116,29 +116,29 @@ class JSONEncoder(json.JSONEncoder):
|
|||
"""JSONEncoder that supports Home Assistant objects."""
|
||||
|
||||
# pylint: disable=method-hidden
|
||||
def default(self, obj):
|
||||
def default(self, o):
|
||||
"""Convert Home Assistant objects.
|
||||
|
||||
Hand other objects to the original method.
|
||||
"""
|
||||
if isinstance(obj, datetime):
|
||||
return obj.isoformat()
|
||||
elif isinstance(obj, set):
|
||||
return list(obj)
|
||||
elif hasattr(obj, 'as_dict'):
|
||||
return obj.as_dict()
|
||||
if isinstance(o, datetime):
|
||||
return o.isoformat()
|
||||
elif isinstance(o, set):
|
||||
return list(o)
|
||||
elif hasattr(o, 'as_dict'):
|
||||
return o.as_dict()
|
||||
|
||||
try:
|
||||
return json.JSONEncoder.default(self, obj)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
except TypeError:
|
||||
# If the JSON serializer couldn't serialize it
|
||||
# it might be a generator, convert it to a list
|
||||
try:
|
||||
return [self.default(child_obj)
|
||||
for child_obj in obj]
|
||||
for child_obj in o]
|
||||
except TypeError:
|
||||
# Ok, we're lost, cause the original error
|
||||
return json.JSONEncoder.default(self, obj)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
||||
|
||||
def validate_api(api):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue