diff --git a/homeassistant/remote.py b/homeassistant/remote.py index acea245ec06..f3be9b8075b 100644 --- a/homeassistant/remote.py +++ b/homeassistant/remote.py @@ -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: diff --git a/homeassistant/remote_json.py b/homeassistant/remote_json.py new file mode 100644 index 00000000000..ca540ac34ca --- /dev/null +++ b/homeassistant/remote_json.py @@ -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) diff --git a/pylintrc b/pylintrc index 28d50902f2a..4ccaaceaa11 100644 --- a/pylintrc +++ b/pylintrc @@ -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