mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Upgrade pydocstyle to 4.0.0, do not run in tox (#25667)
* Upgrade pydocstyle to 4.0.0 and flake8-docstrings to 1.3.1 http://www.pydocstyle.org/en/4.0.0/release_notes.html#july-6th-2019 * Address pydocstyle D413's * tox: do not run pydocstyle Does not seem to add any value over flake8-docstrings (and would have needed a D202 exclusion).
This commit is contained in:
parent
c748d8c0bd
commit
49a5dda7a8
@ -6,6 +6,7 @@ from numbers import Number
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -333,17 +334,21 @@ class FilterState:
|
|||||||
|
|
||||||
|
|
||||||
class Filter:
|
class Filter:
|
||||||
"""Filter skeleton.
|
"""Filter skeleton."""
|
||||||
|
|
||||||
Args:
|
def __init__(
|
||||||
window_size (int): size of the sliding window that holds previous
|
self,
|
||||||
values
|
name,
|
||||||
precision (int): round filtered value to precision value
|
window_size: int = 1,
|
||||||
entity (string): used for debugging only
|
precision: Optional[int] = None,
|
||||||
"""
|
entity: Optional[str] = None,
|
||||||
|
):
|
||||||
|
"""Initialize common attributes.
|
||||||
|
|
||||||
def __init__(self, name, window_size=1, precision=None, entity=None):
|
:param window_size: size of the sliding window that holds previous values
|
||||||
"""Initialize common attributes."""
|
:param precision: round filtered value to precision value
|
||||||
|
:param entity: used for debugging only
|
||||||
|
"""
|
||||||
if isinstance(window_size, int):
|
if isinstance(window_size, int):
|
||||||
self.states = deque(maxlen=window_size)
|
self.states = deque(maxlen=window_size)
|
||||||
self.window_unit = WINDOW_SIZE_UNIT_NUMBER_EVENTS
|
self.window_unit = WINDOW_SIZE_UNIT_NUMBER_EVENTS
|
||||||
@ -394,14 +399,19 @@ class RangeFilter(Filter):
|
|||||||
|
|
||||||
Determines if new state is in the range of upper_bound and lower_bound.
|
Determines if new state is in the range of upper_bound and lower_bound.
|
||||||
If not inside, lower or upper bound is returned instead.
|
If not inside, lower or upper bound is returned instead.
|
||||||
|
|
||||||
Args:
|
|
||||||
upper_bound (float): band upper bound
|
|
||||||
lower_bound (float): band lower bound
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, entity, lower_bound=None, upper_bound=None):
|
def __init__(
|
||||||
"""Initialize Filter."""
|
self,
|
||||||
|
entity,
|
||||||
|
lower_bound: Optional[float] = None,
|
||||||
|
upper_bound: Optional[float] = None,
|
||||||
|
):
|
||||||
|
"""Initialize Filter.
|
||||||
|
|
||||||
|
:param upper_bound: band upper bound
|
||||||
|
:param lower_bound: band lower bound
|
||||||
|
"""
|
||||||
super().__init__(FILTER_NAME_RANGE, entity=entity)
|
super().__init__(FILTER_NAME_RANGE, entity=entity)
|
||||||
self._lower_bound = lower_bound
|
self._lower_bound = lower_bound
|
||||||
self._upper_bound = upper_bound
|
self._upper_bound = upper_bound
|
||||||
@ -441,13 +451,13 @@ class OutlierFilter(Filter):
|
|||||||
"""BASIC outlier filter.
|
"""BASIC outlier filter.
|
||||||
|
|
||||||
Determines if new state is in a band around the median.
|
Determines if new state is in a band around the median.
|
||||||
|
|
||||||
Args:
|
|
||||||
radius (float): band radius
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, window_size, precision, entity, radius):
|
def __init__(self, window_size, precision, entity, radius: float):
|
||||||
"""Initialize Filter."""
|
"""Initialize Filter.
|
||||||
|
|
||||||
|
:param radius: band radius
|
||||||
|
"""
|
||||||
super().__init__(FILTER_NAME_OUTLIER, window_size, precision, entity)
|
super().__init__(FILTER_NAME_OUTLIER, window_size, precision, entity)
|
||||||
self._radius = radius
|
self._radius = radius
|
||||||
self._stats_internal = Counter()
|
self._stats_internal = Counter()
|
||||||
@ -475,13 +485,9 @@ class OutlierFilter(Filter):
|
|||||||
|
|
||||||
@FILTERS.register(FILTER_NAME_LOWPASS)
|
@FILTERS.register(FILTER_NAME_LOWPASS)
|
||||||
class LowPassFilter(Filter):
|
class LowPassFilter(Filter):
|
||||||
"""BASIC Low Pass Filter.
|
"""BASIC Low Pass Filter."""
|
||||||
|
|
||||||
Args:
|
def __init__(self, window_size, precision, entity, time_constant: int):
|
||||||
time_constant (int): time constant.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, window_size, precision, entity, time_constant):
|
|
||||||
"""Initialize Filter."""
|
"""Initialize Filter."""
|
||||||
super().__init__(FILTER_NAME_LOWPASS, window_size, precision, entity)
|
super().__init__(FILTER_NAME_LOWPASS, window_size, precision, entity)
|
||||||
self._time_constant = time_constant
|
self._time_constant = time_constant
|
||||||
@ -505,15 +511,15 @@ class TimeSMAFilter(Filter):
|
|||||||
"""Simple Moving Average (SMA) Filter.
|
"""Simple Moving Average (SMA) Filter.
|
||||||
|
|
||||||
The window_size is determined by time, and SMA is time weighted.
|
The window_size is determined by time, and SMA is time weighted.
|
||||||
|
|
||||||
Args:
|
|
||||||
type (enum): type of algorithm used to connect discrete values
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, window_size, precision, entity, type
|
self, window_size, precision, entity, type
|
||||||
): # pylint: disable=redefined-builtin
|
): # pylint: disable=redefined-builtin
|
||||||
"""Initialize Filter."""
|
"""Initialize Filter.
|
||||||
|
|
||||||
|
:param type: type of algorithm used to connect discrete values
|
||||||
|
"""
|
||||||
super().__init__(FILTER_NAME_TIME_SMA, window_size, precision, entity)
|
super().__init__(FILTER_NAME_TIME_SMA, window_size, precision, entity)
|
||||||
self._time_window = window_size
|
self._time_window = window_size
|
||||||
self.last_leak = None
|
self.last_leak = None
|
||||||
|
@ -89,6 +89,7 @@ async def schedule_future_update(hass, sensors, midnight_time, prayer_times_data
|
|||||||
|
|
||||||
calculated midnight = 1:35AM (after traditional midnight)
|
calculated midnight = 1:35AM (after traditional midnight)
|
||||||
update time: 1:36AM.
|
update time: 1:36AM.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_LOGGER.debug("Scheduling next update for Islamic prayer times")
|
_LOGGER.debug("Scheduling next update for Islamic prayer times")
|
||||||
|
|
||||||
|
@ -55,9 +55,8 @@ class LW12WiFi(Light):
|
|||||||
def __init__(self, name, lw12_light):
|
def __init__(self, name, lw12_light):
|
||||||
"""Initialise LW-12 WiFi LED Controller.
|
"""Initialise LW-12 WiFi LED Controller.
|
||||||
|
|
||||||
Args:
|
:param name: Friendly name for this platform to use.
|
||||||
name: Friendly name for this platform to use.
|
:param lw12_light: Instance of the LW12 controller.
|
||||||
lw12_light: Instance of the LW12 controller.
|
|
||||||
"""
|
"""
|
||||||
self._light = lw12_light
|
self._light = lw12_light
|
||||||
self._name = name
|
self._name = name
|
||||||
|
@ -3,6 +3,7 @@ import asyncio
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
from typing import Any, Callable, Optional, Union
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
import async_timeout
|
||||||
@ -56,29 +57,25 @@ class WUSensorConfig:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
friendly_name,
|
friendly_name: Union[str, Callable],
|
||||||
feature,
|
feature: str,
|
||||||
value,
|
value: Callable[["WUndergroundData"], Any],
|
||||||
unit_of_measurement=None,
|
unit_of_measurement: Optional[str] = None,
|
||||||
entity_picture=None,
|
entity_picture=None,
|
||||||
icon="mdi:gauge",
|
icon: str = "mdi:gauge",
|
||||||
device_state_attributes=None,
|
device_state_attributes=None,
|
||||||
device_class=None,
|
device_class=None,
|
||||||
):
|
):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param friendly_name: Friendly name
|
||||||
friendly_name (string|func): Friendly name
|
:param feature: WU feature. See:
|
||||||
feature (string): WU feature. See:
|
|
||||||
https://www.wunderground.com/weather/api/d/docs?d=data/index
|
https://www.wunderground.com/weather/api/d/docs?d=data/index
|
||||||
value (function(WUndergroundData)): callback that
|
:param value: callback that extracts desired value from WUndergroundData object
|
||||||
extracts desired value from WUndergroundData object
|
:param unit_of_measurement: unit of measurement
|
||||||
unit_of_measurement (string): unit of measurement
|
:param entity_picture: value or callback returning URL of entity picture
|
||||||
entity_picture (string): value or callback returning
|
:param icon: icon name or URL
|
||||||
URL of entity picture
|
:param device_state_attributes: dictionary of attributes, or callable that returns it
|
||||||
icon (string): icon name or URL
|
|
||||||
device_state_attributes (dict): dictionary of attributes,
|
|
||||||
or callable that returns it
|
|
||||||
"""
|
"""
|
||||||
self.friendly_name = friendly_name
|
self.friendly_name = friendly_name
|
||||||
self.unit_of_measurement = unit_of_measurement
|
self.unit_of_measurement = unit_of_measurement
|
||||||
@ -95,21 +92,18 @@ class WUCurrentConditionsSensorConfig(WUSensorConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
friendly_name,
|
friendly_name: Union[str, Callable],
|
||||||
field,
|
field: str,
|
||||||
icon="mdi:gauge",
|
icon: Optional[str] = "mdi:gauge",
|
||||||
unit_of_measurement=None,
|
unit_of_measurement: Optional[str] = None,
|
||||||
device_class=None,
|
device_class=None,
|
||||||
):
|
):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param friendly_name: Friendly name of sensor
|
||||||
friendly_name (string|func): Friendly name of sensor
|
:field: Field name in the "current_observation" dictionary.
|
||||||
field (string): Field name in the "current_observation"
|
:icon: icon name or URL, if None sensor will use current weather symbol
|
||||||
dictionary.
|
:unit_of_measurement: unit of measurement
|
||||||
icon (string): icon name or URL, if None sensor
|
|
||||||
will use current weather symbol
|
|
||||||
unit_of_measurement (string): unit of measurement
|
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
friendly_name,
|
friendly_name,
|
||||||
@ -130,13 +124,14 @@ class WUCurrentConditionsSensorConfig(WUSensorConfig):
|
|||||||
class WUDailyTextForecastSensorConfig(WUSensorConfig):
|
class WUDailyTextForecastSensorConfig(WUSensorConfig):
|
||||||
"""Helper for defining sensor configurations for daily text forecasts."""
|
"""Helper for defining sensor configurations for daily text forecasts."""
|
||||||
|
|
||||||
def __init__(self, period, field, unit_of_measurement=None):
|
def __init__(
|
||||||
|
self, period: int, field: str, unit_of_measurement: Optional[str] = None
|
||||||
|
):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param period: forecast period number
|
||||||
period (int): forecast period number
|
:param field: field name to use as value
|
||||||
field (string): field name to use as value
|
:param unit_of_measurement: unit of measurement
|
||||||
unit_of_measurement(string): unit of measurement
|
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
friendly_name=lambda wu: wu.data["forecast"]["txt_forecast"]["forecastday"][
|
friendly_name=lambda wu: wu.data["forecast"]["txt_forecast"]["forecastday"][
|
||||||
@ -161,24 +156,22 @@ class WUDailySimpleForecastSensorConfig(WUSensorConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
friendly_name,
|
friendly_name: str,
|
||||||
period,
|
period: int,
|
||||||
field,
|
field: str,
|
||||||
wu_unit=None,
|
wu_unit: Optional[str] = None,
|
||||||
ha_unit=None,
|
ha_unit: Optional[str] = None,
|
||||||
icon=None,
|
icon=None,
|
||||||
device_class=None,
|
device_class=None,
|
||||||
):
|
):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param friendly_name: friendly_name of the sensor
|
||||||
period (int): forecast period number
|
:param period: forecast period number
|
||||||
field (string): field name to use as value
|
:param field: field name to use as value
|
||||||
wu_unit (string): "fahrenheit", "celsius", "degrees" etc.
|
:param wu_unit: "fahrenheit", "celsius", "degrees" etc. see the example json at:
|
||||||
see the example json at:
|
https://www.wunderground.com/weather/api/d/docs?d=data/forecast&MR=1
|
||||||
https://www.wunderground.com/weather/api/d/docs?d=data/forecast&MR=1
|
:param ha_unit: corresponding unit in home assistant
|
||||||
ha_unit (string): corresponding unit in home assistant
|
|
||||||
title (string): friendly_name of the sensor
|
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
friendly_name=friendly_name,
|
friendly_name=friendly_name,
|
||||||
@ -213,12 +206,11 @@ class WUDailySimpleForecastSensorConfig(WUSensorConfig):
|
|||||||
class WUHourlyForecastSensorConfig(WUSensorConfig):
|
class WUHourlyForecastSensorConfig(WUSensorConfig):
|
||||||
"""Helper for defining sensor configurations for hourly text forecasts."""
|
"""Helper for defining sensor configurations for hourly text forecasts."""
|
||||||
|
|
||||||
def __init__(self, period, field):
|
def __init__(self, period: int, field: int):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param period: forecast period number
|
||||||
period (int): forecast period number
|
:param field: field name to use as value
|
||||||
field (int): field name to use as value
|
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
friendly_name=lambda wu: "{} {}".format(
|
friendly_name=lambda wu: "{} {}".format(
|
||||||
@ -274,24 +266,22 @@ class WUAlmanacSensorConfig(WUSensorConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
friendly_name,
|
friendly_name: Union[str, Callable],
|
||||||
field,
|
field: str,
|
||||||
value_type,
|
value_type: str,
|
||||||
wu_unit,
|
wu_unit: str,
|
||||||
unit_of_measurement,
|
unit_of_measurement: str,
|
||||||
icon,
|
icon: str,
|
||||||
device_class=None,
|
device_class=None,
|
||||||
):
|
):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param friendly_name: Friendly name
|
||||||
friendly_name (string|func): Friendly name
|
:param field: value name returned in 'almanac' dict as returned by the WU API
|
||||||
field (string): value name returned in 'almanac' dict
|
:param value_type: "record" or "normal"
|
||||||
as returned by the WU API
|
:param wu_unit: unit name in WU API
|
||||||
value_type (string): "record" or "normal"
|
:param unit_of_measurement: unit of measurement
|
||||||
wu_unit (string): unit name in WU API
|
:param icon: icon name or URL
|
||||||
icon (string): icon name or URL
|
|
||||||
unit_of_measurement (string): unit of measurement
|
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
friendly_name=friendly_name,
|
friendly_name=friendly_name,
|
||||||
@ -306,11 +296,10 @@ class WUAlmanacSensorConfig(WUSensorConfig):
|
|||||||
class WUAlertsSensorConfig(WUSensorConfig):
|
class WUAlertsSensorConfig(WUSensorConfig):
|
||||||
"""Helper for defining field configuration for alerts."""
|
"""Helper for defining field configuration for alerts."""
|
||||||
|
|
||||||
def __init__(self, friendly_name):
|
def __init__(self, friendly_name: Union[str, Callable]):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
:param friendly_name: Friendly name
|
||||||
friendly_name (string|func): Friendly name
|
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
friendly_name=friendly_name,
|
friendly_name=friendly_name,
|
||||||
|
@ -40,6 +40,7 @@ def _include_yaml(
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
device_tracker: !include device_tracker.yaml
|
device_tracker: !include device_tracker.yaml
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if constructor.name is None:
|
if constructor.name is None:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
|
@ -113,6 +113,7 @@ def _include_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
device_tracker: !include device_tracker.yaml
|
device_tracker: !include device_tracker.yaml
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fname = os.path.join(os.path.dirname(loader.name), node.value)
|
fname = os.path.join(os.path.dirname(loader.name), node.value)
|
||||||
return _add_reference(load_yaml(fname), loader, node)
|
return _add_reference(load_yaml(fname), loader, node)
|
||||||
|
@ -7,11 +7,11 @@ asynctest==0.13.0
|
|||||||
black==19.3b0
|
black==19.3b0
|
||||||
codecov==2.0.15
|
codecov==2.0.15
|
||||||
coveralls==1.2.0
|
coveralls==1.2.0
|
||||||
flake8-docstrings==1.3.0
|
flake8-docstrings==1.3.1
|
||||||
flake8==3.7.8
|
flake8==3.7.8
|
||||||
mock-open==1.3.1
|
mock-open==1.3.1
|
||||||
mypy==0.720
|
mypy==0.720
|
||||||
pydocstyle==3.0.0
|
pydocstyle==4.0.0
|
||||||
pylint==2.3.1
|
pylint==2.3.1
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
pytest-cov==2.7.1
|
pytest-cov==2.7.1
|
||||||
|
@ -8,11 +8,11 @@ asynctest==0.13.0
|
|||||||
black==19.3b0
|
black==19.3b0
|
||||||
codecov==2.0.15
|
codecov==2.0.15
|
||||||
coveralls==1.2.0
|
coveralls==1.2.0
|
||||||
flake8-docstrings==1.3.0
|
flake8-docstrings==1.3.1
|
||||||
flake8==3.7.8
|
flake8==3.7.8
|
||||||
mock-open==1.3.1
|
mock-open==1.3.1
|
||||||
mypy==0.720
|
mypy==0.720
|
||||||
pydocstyle==3.0.0
|
pydocstyle==4.0.0
|
||||||
pylint==2.3.1
|
pylint==2.3.1
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
pytest-cov==2.7.1
|
pytest-cov==2.7.1
|
||||||
|
1
tox.ini
1
tox.ini
@ -35,7 +35,6 @@ commands =
|
|||||||
python -m script.gen_requirements_all validate
|
python -m script.gen_requirements_all validate
|
||||||
python -m script.hassfest validate
|
python -m script.hassfest validate
|
||||||
flake8 {posargs: homeassistant tests script}
|
flake8 {posargs: homeassistant tests script}
|
||||||
pydocstyle {posargs:homeassistant tests}
|
|
||||||
|
|
||||||
[testenv:typing]
|
[testenv:typing]
|
||||||
whitelist_externals=/bin/bash
|
whitelist_externals=/bin/bash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user