mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Work around a pylint bug
This commit is contained in:
parent
feeeac2a75
commit
a391bc3d3f
@ -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:
|
||||
|
21
homeassistant/remote_json.py
Normal file
21
homeassistant/remote_json.py
Normal 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)
|
7
pylintrc
7
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user