Fix lint issues for 0.33 (#4451)

* Fix PEP257 issues

* Fix ident

* Fix lint issues

* Update docstrings

* Fix indent

* Fix indent

* Fix lint issues

* Fix lint issue

* Again lint
This commit is contained in:
Fabian Affolter 2016-11-18 23:05:03 +01:00 committed by GitHub
parent c86e1b31b3
commit e6c4113c5b
7 changed files with 76 additions and 61 deletions

View file

@ -1,5 +1,5 @@
"""
Support for ZWave climate devices.
Support for Z-Wave climate devices.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/climate.zwave/
@ -17,7 +17,7 @@ from homeassistant.const import (
_LOGGER = logging.getLogger(__name__)
CONF_NAME = 'name'
DEFAULT_NAME = 'ZWave Climate'
DEFAULT_NAME = 'Z-Wave Climate'
REMOTEC = 0x5254
REMOTEC_ZXT_120 = 0x8377
@ -33,7 +33,7 @@ DEVICE_MAPPINGS = {
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the ZWave Climate devices."""
"""Set up the Z-Wave Climate devices."""
if discovery_info is None or zwave.NETWORK is None:
_LOGGER.debug("No discovery_info=%s or no NETWORK=%s",
discovery_info, zwave.NETWORK)
@ -48,10 +48,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
"""Represents a ZWave Climate device."""
"""Representation of a Z-Wave Climate device."""
def __init__(self, value, temp_unit):
"""Initialize the zwave climate device."""
"""Initialize the Z-Wave climate device."""
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
ZWaveDeviceEntity.__init__(self, value, DOMAIN)
@ -162,7 +162,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
@property
def should_poll(self):
"""No polling on ZWave."""
"""No polling on Z-Wave."""
return False
@property

View file

@ -86,14 +86,13 @@ class SwisscomDeviceScanner(object):
def get_swisscom_data(self):
"""Retrieve data from Swisscom and return parsed result."""
request = requests.post('http://' + self.host + '/ws', headers={
'Content-Type': 'application/x-sah-ws-4-call+json'
},
data="""{"service":"Devices",
"method":"get",
"parameters":
{"expression":"lan and not self"}}""",
timeout=10)
url = 'http://{}/ws'.format(self.host)
headers = {'Content-Type': 'application/x-sah-ws-4-call+json'}
data = """
{"service":"Devices", "method":"get",
"parameters":{"expression":"lan and not self"}}"""
request = requests.post(url, headers=headers, data=data, timeout=10)
devices = {}
for device in request.json()['status']:

View file

@ -125,8 +125,8 @@ class WUndergroundSensor(Entity):
"""Return the state of the sensor."""
if self.rest.data:
if self._condition == 'elevation' and \
self._condition in self.rest.data['observation_location']:
if self._condition == 'elevation' and self._condition in \
self.rest.data['observation_location']:
return self.rest.data['observation_location'][self._condition]\
.split()[0]

View file

@ -29,11 +29,11 @@ _LOGGER = logging.getLogger(__name__)
def get_test_config_dir(*add_path):
"""Return a path to a test config dir."""
return os.path.join(os.path.dirname(__file__), "testing_config", *add_path)
return os.path.join(os.path.dirname(__file__), 'testing_config', *add_path)
def get_test_home_assistant():
"""Return a Home Assistant object pointing at test config dir."""
"""Return a Home Assistant object pointing at test config directory."""
if sys.platform == "win32":
loop = asyncio.ProactorEventLoop()
else:
@ -75,6 +75,7 @@ def get_test_home_assistant():
return hass
# pylint: disable=protected-access
@asyncio.coroutine
def async_test_home_assistant(loop):
"""Return a Home Assistant object pointing at test config dir."""
@ -101,6 +102,7 @@ def async_test_home_assistant(loop):
@asyncio.coroutine
def mock_async_start():
"""Start the mocking."""
with patch.object(loop, 'add_signal_handler'),\
patch('homeassistant.core._async_create_timer'),\
patch.object(hass, '_async_tasks_cleanup', return_value=None):
@ -130,8 +132,10 @@ def mock_service(hass, domain, service):
"""
calls = []
# pylint: disable=redefined-outer-name
@ha.callback
def mock_service(call):
""""Mocked service call."""
calls.append(call)
# pylint: disable=unnecessary-lambda

View file

@ -8,8 +8,8 @@ import rxv
def sample_content(name):
"""Read content into a string from a file."""
with open('tests/components/media_player/yamaha_samples/%s' % name,
encoding='utf-8') as f:
return f.read()
encoding='utf-8') as content:
return content.read()
class FakeYamaha(rxv.rxv.RXV):
@ -20,21 +20,25 @@ class FakeYamaha(rxv.rxv.RXV):
ensure that usage of the rxv library by HomeAssistant is as we'd
expect.
"""
_fake_input = "HDMI1"
_fake_input = 'HDMI1'
def _discover_features(self):
self._desc_xml = ET.fromstring(sample_content("desc.xml"))
"""Fake the discovery feature."""
self._desc_xml = ET.fromstring(sample_content('desc.xml'))
@property
def input(self):
"""A fake input for the reciever."""
return self._fake_input
@input.setter
def input(self, input_name):
"""Set the input for the fake receiver."""
assert input_name in self.inputs()
self._fake_input = input_name
def inputs(self):
"""All inputs of the the fake receiver."""
return {'AUDIO1': None,
'AUDIO2': None,
'AV1': None,
@ -61,15 +65,17 @@ class FakeYamaha(rxv.rxv.RXV):
'iPod (USB)': 'iPod_USB'}
# pylint: disable=no-member, invalid-name
class TestYamaha(unittest.TestCase):
"""Test the media_player yamaha module."""
def setUp(self): # pylint: disable=invalid-name
def setUp(self):
"""Setup things to be run when tests are started."""
super(TestYamaha, self).setUp()
self.rec = FakeYamaha('10.0.0.0')
def test_get_playback_support(self):
"""Test the playback"""
rec = self.rec
support = rec.get_playback_support()
self.assertFalse(support.play)
@ -78,7 +84,7 @@ class TestYamaha(unittest.TestCase):
self.assertFalse(support.skip_f)
self.assertFalse(support.skip_r)
rec.input = "NET RADIO"
rec.input = 'NET RADIO'
support = rec.get_playback_support()
self.assertTrue(support.play)
self.assertFalse(support.pause)

View file

@ -1,4 +1,4 @@
"""the tests for the Command line switch platform."""
"""The tests for the Command line switch platform."""
import json
import os
import tempfile
@ -12,14 +12,15 @@ import homeassistant.components.switch.command_line as command_line
from tests.common import get_test_home_assistant
# pylint: disable=invalid-name
class TestCommandSwitch(unittest.TestCase):
"""Test the command switch."""
def setUp(self): # pylint: disable=invalid-name
def setUp(self):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
def tearDown(self): # pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
@ -171,7 +172,7 @@ class TestCommandSwitch(unittest.TestCase):
"echo 'on command'",
"echo 'off command'",
False,
None
None,
]
no_state_device = command_line.CommandSwitch(*init_args)
@ -194,7 +195,7 @@ class TestCommandSwitch(unittest.TestCase):
"echo 'on command'",
"echo 'off command'",
False,
None
None,
]
test_switch = command_line.CommandSwitch(*init_args)

View file

@ -17,7 +17,7 @@ from tests.common import get_test_instance_port, get_test_home_assistant
HTTP_SERVER_PORT = get_test_instance_port()
BRIDGE_SERVER_PORT = get_test_instance_port()
BRIDGE_URL_BASE = "http://127.0.0.1:{}".format(BRIDGE_SERVER_PORT) + "{}"
BRIDGE_URL_BASE = 'http://127.0.0.1:{}'.format(BRIDGE_SERVER_PORT) + '{}'
JSON_HEADERS = {const.HTTP_HEADER_CONTENT_TYPE: const.CONTENT_TYPE_JSON}
@ -75,6 +75,7 @@ class TestEmulatedHue(unittest.TestCase):
self.assertTrue('text/xml' in result.headers['content-type'])
# Make sure the XML is parsable
# pylint: disable=bare-except
try:
ET.fromstring(result.text)
except:
@ -134,7 +135,8 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
'set_kitchen_light': {
'sequence': [
{
'service_template': "light.turn_{{ requested_state }}",
'service_template':
"light.turn_{{ requested_state }}",
'data_template': {
'entity_id': 'light.kitchen_lights',
'brightness': "{{ requested_level }}"
@ -285,6 +287,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
kitchen_light.attributes[light.ATTR_BRIGHTNESS],
level)
# pylint: disable=invalid-name
def test_put_with_form_urlencoded_content_type(self):
"""Test the form with urlencoded content."""
# Needed for Alexa
@ -296,7 +299,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
result = requests.put(
BRIDGE_URL_BASE.format(
'/api/username/lights/{}/state'.format(
"light.ceiling_lights")), data=data)
'light.ceiling_lights')), data=data)
self.assertEqual(result.status_code, 400)
@ -344,7 +347,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
result = requests.put(
BRIDGE_URL_BASE.format(
'/api/username/lights/{}/state'.format(
"light.ceiling_lights")),
'light.ceiling_lights')),
data=json.dumps({HUE_API_STATE_ON: 1234}))
self.assertEqual(result.status_code, 400)
@ -353,13 +356,14 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
result = requests.put(
BRIDGE_URL_BASE.format(
'/api/username/lights/{}/state'.format(
"light.ceiling_lights")), data=json.dumps({
'light.ceiling_lights')), data=json.dumps({
HUE_API_STATE_ON: True,
HUE_API_STATE_BRI: 'Hello world!'
}))
self.assertEqual(result.status_code, 400)
# pylint: disable=invalid-name
def perform_put_test_on_ceiling_lights(self,
content_type='application/json'):
"""Test the setting of a light."""
@ -405,6 +409,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
return None
# pylint: disable=no-self-use
def perform_put_light_state(self, entity_id, is_on, brightness=None,
content_type='application/json'):
"""Test the setting of a light state."""