Update docstrings (#7361)

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update tomato.py

* Update isy994.py

* Lint + fix tests

* Lint
This commit is contained in:
Fabian Affolter
2017-04-29 22:04:49 -07:00
committed by Paulus Schoutsen
parent e22e70a01a
commit 3ee4d1060f
264 changed files with 1686 additions and 1768 deletions
+7 -11
View File
@@ -1,30 +1,26 @@
"""Temperature util functions."""
from homeassistant.const import (
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UNIT_NOT_RECOGNIZED_TEMPLATE,
TEMPERATURE
)
TEMP_CELSIUS, TEMP_FAHRENHEIT, UNIT_NOT_RECOGNIZED_TEMPLATE, TEMPERATURE)
def fahrenheit_to_celsius(fahrenheit: float) -> float:
"""Convert a Fahrenheit temperature to Celsius."""
"""Convert a temperature in Fahrenheit to Celsius."""
return (fahrenheit - 32.0) / 1.8
def celsius_to_fahrenheit(celsius: float) -> float:
"""Convert a Celsius temperature to Fahrenheit."""
"""Convert a temperature in Celsius to Fahrenheit."""
return celsius * 1.8 + 32.0
def convert(temperature: float, from_unit: str, to_unit: str) -> float:
"""Convert a temperature from one unit to another."""
if from_unit not in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(from_unit,
TEMPERATURE))
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(
from_unit, TEMPERATURE))
if to_unit not in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(to_unit,
TEMPERATURE))
raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(
to_unit, TEMPERATURE))
if from_unit == to_unit:
return temperature
+6 -6
View File
@@ -65,12 +65,12 @@ def load_yaml(fname: str) -> Union[List, Dict]:
_LOGGER.error(exc)
raise HomeAssistantError(exc)
except UnicodeDecodeError as exc:
_LOGGER.error('Unable to read file %s: %s', fname, exc)
_LOGGER.error("Unable to read file %s: %s", fname, exc)
raise HomeAssistantError(exc)
def dump(_dict: dict) -> str:
"""Dump yaml to a string and remove null."""
"""Dump YAML to a string and remove null."""
return yaml.safe_dump(_dict, default_flow_style=False) \
.replace(': null\n', ':\n')
@@ -237,8 +237,8 @@ def _secret_yaml(loader: SafeLineLoader,
secrets = _load_secret_yaml(secret_path)
if node.value in secrets:
_LOGGER.debug('Secret %s retrieved from secrets.yaml in '
'folder %s', node.value, secret_path)
_LOGGER.debug("Secret %s retrieved from secrets.yaml in "
"folder %s", node.value, secret_path)
return secrets[node.value]
if secret_path == os.path.dirname(sys.path[0]):
@@ -252,10 +252,10 @@ def _secret_yaml(loader: SafeLineLoader,
# do some keyring stuff
pwd = keyring.get_password(_SECRET_NAMESPACE, node.value)
if pwd:
_LOGGER.debug('Secret %s retrieved from keyring.', node.value)
_LOGGER.debug("Secret %s retrieved from keyring", node.value)
return pwd
_LOGGER.error('Secret %s not defined.', node.value)
_LOGGER.error("Secret %s not defined", node.value)
raise HomeAssistantError(node.value)