Work around a pylint bug

This commit is contained in:
Paulus Schoutsen 2014-11-22 16:56:36 -08:00
parent feeeac2a75
commit a391bc3d3f
3 changed files with 28 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import urllib.parse
import requests
import homeassistant as ha
from homeassistant.remote_json import JSONEncoder
SERVER_PORT = 8123
@ -238,18 +239,6 @@ class StateMachine(ha.StateMachine):
self._states[event.data['entity_id']] = event.data['new_state']
class JSONEncoder(json.JSONEncoder):
""" JSONEncoder that supports Home Assistant objects. """
def default(self, obj): # pylint: disable=method-hidden
""" Checks if Home Assistat object and encodes if possible.
Else hand it off to original method. """
if isinstance(obj, ha.State):
return obj.as_dict()
return json.JSONEncoder.default(self, obj)
def validate_api(api):
""" Makes a call to validate API. """
try:

View File

@ -0,0 +1,21 @@
# pylint: skip-file
"""
Helper methods for using JSON.
This used to be in homeassistant.remote but has been moved
to this module because of a bug in PyLint that would make it crash.
"""
import homeassistant as ha
import json
class JSONEncoder(json.JSONEncoder):
""" JSONEncoder that supports Home Assistant objects. """
def default(self, obj):
""" Checks if Home Assistat object and encodes if possible.
Else hand it off to original method. """
if isinstance(obj, ha.State):
return obj.as_dict()
return json.JSONEncoder.default(self, obj)

View File

@ -6,7 +6,12 @@ reports=no
# locally-disabled - it spams too much
# duplicate-code - unavoidable
# cyclic-import - doesn't test if both import on load
disable=locally-disabled,duplicate-code,cyclic-import
# file-ignored - we ignore a file to work around a pylint bug
disable=
locally-disabled,
duplicate-code,
cyclic-import,
file-ignored
[EXCEPTIONS]
overgeneral-exceptions=Exception,HomeAssistantError