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-30 07:04:49 +02:00 committed by Paulus Schoutsen
parent e22e70a01a
commit 3ee4d1060f
264 changed files with 1686 additions and 1768 deletions

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