From 6879e39d6c658f0a4dc03c8952bea8cc8884c6ef Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 7 Mar 2016 22:13:18 +0100 Subject: [PATCH] Fix PEP257 issues --- homeassistant/components/lock/__init__.py | 17 +++++++++-------- homeassistant/components/lock/demo.py | 6 ++++-- homeassistant/components/lock/mqtt.py | 2 ++ homeassistant/components/lock/verisure.py | 12 +++++++----- homeassistant/components/lock/wink.py | 4 +++- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index 4cfb899d56f..d84abb87248 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -41,13 +41,13 @@ _LOGGER = logging.getLogger(__name__) def is_locked(hass, entity_id=None): - """Returns if the lock is locked based on the statemachine.""" + """Return if the lock is locked based on the statemachine.""" entity_id = entity_id or ENTITY_ID_ALL_LOCKS return hass.states.is_state(entity_id, STATE_LOCKED) def lock(hass, entity_id=None, code=None): - """Locks all or specified locks.""" + """Lock all or specified locks.""" data = {} if code: data[ATTR_CODE] = code @@ -58,7 +58,7 @@ def lock(hass, entity_id=None, code=None): def unlock(hass, entity_id=None, code=None): - """Unlocks all or specified locks.""" + """Unlock all or specified locks.""" data = {} if code: data[ATTR_CODE] = code @@ -76,7 +76,7 @@ def setup(hass, config): component.setup(config) def handle_lock_service(service): - """Handles calls to the lock services.""" + """Handle calls to the lock services.""" target_locks = component.extract_from_service(service) if ATTR_CODE not in service.data: @@ -104,7 +104,8 @@ def setup(hass, config): class LockDevice(Entity): - """Represents a lock.""" + """Representation of a lock.""" + # pylint: disable=no-self-use @property def code_format(self): @@ -113,15 +114,15 @@ class LockDevice(Entity): @property def is_locked(self): - """Is the lock locked or unlocked.""" + """Return true if the lock is locked.""" return None def lock(self, **kwargs): - """Locks the lock.""" + """Lock the lock.""" raise NotImplementedError() def unlock(self, **kwargs): - """Unlocks the lock.""" + """Unlock the lock.""" raise NotImplementedError() @property diff --git a/homeassistant/components/lock/demo.py b/homeassistant/components/lock/demo.py index 319ee760e57..06366429e6c 100644 --- a/homeassistant/components/lock/demo.py +++ b/homeassistant/components/lock/demo.py @@ -10,7 +10,7 @@ from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """Setup the demo lock platform. """ + """Setup the demo lock platform.""" add_devices_callback([ DemoLock('Front Door', STATE_LOCKED), DemoLock('Kitchen Door', STATE_UNLOCKED) @@ -18,8 +18,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): class DemoLock(LockDevice): - """Provides a demo lock.""" + """Representation of a demo lock.""" + def __init__(self, name, state): + """Initialize the lock.""" self._name = name self._state = state diff --git a/homeassistant/components/lock/mqtt.py b/homeassistant/components/lock/mqtt.py index cea52a94838..a68a3303de6 100644 --- a/homeassistant/components/lock/mqtt.py +++ b/homeassistant/components/lock/mqtt.py @@ -46,8 +46,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): # pylint: disable=too-many-arguments, too-many-instance-attributes class MqttLock(LockDevice): """Represents a lock that can be toggled using MQTT.""" + def __init__(self, hass, name, state_topic, command_topic, qos, retain, payload_lock, payload_unlock, optimistic, value_template): + """Initialize the lock.""" self._state = False self._hass = hass self._name = name diff --git a/homeassistant/components/lock/verisure.py b/homeassistant/components/lock/verisure.py index 8a2a2a13d9d..4d42aca666f 100644 --- a/homeassistant/components/lock/verisure.py +++ b/homeassistant/components/lock/verisure.py @@ -15,7 +15,7 @@ ATTR_CODE = 'code' def setup_platform(hass, config, add_devices, discovery_info=None): - """Sets up the Verisure platform.""" + """Setup the Verisure platform.""" locks = [] if int(hub.config.get('locks', '1')): hub.update_locks() @@ -28,25 +28,27 @@ def setup_platform(hass, config, add_devices, discovery_info=None): # pylint: disable=abstract-method class VerisureDoorlock(LockDevice): - """Represents a Verisure doorlock.""" + """Representation of a Verisure doorlock.""" + def __init__(self, device_id): + """Initialize the lock.""" self._id = device_id self._state = STATE_UNKNOWN self._digits = int(hub.config.get('code_digits', '4')) @property def name(self): - """Returns the name of the lock.""" + """Return the name of the lock.""" return 'Lock {}'.format(self._id) @property def state(self): - """Returns the state of the lock.""" + """Return the state of the lock.""" return self._state @property def code_format(self): - """Six digit code required.""" + """Return the required six digit code.""" return '^\\d{%s}$' % self._digits def update(self): diff --git a/homeassistant/components/lock/wink.py b/homeassistant/components/lock/wink.py index 02ff23f1036..a78713afce1 100644 --- a/homeassistant/components/lock/wink.py +++ b/homeassistant/components/lock/wink.py @@ -31,8 +31,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class WinkLockDevice(LockDevice): - """Represents a Wink lock.""" + """Representation of a Wink lock.""" + def __init__(self, wink): + """Initialize the lock.""" self.wink = wink @property