mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +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 copy import copy
|
||||
from datetime import timedelta
|
||||
from typing import Optional
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -333,17 +334,21 @@ class FilterState:
|
||||
|
||||
|
||||
class Filter:
|
||||
"""Filter skeleton.
|
||||
"""Filter skeleton."""
|
||||
|
||||
Args:
|
||||
window_size (int): size of the sliding window that holds previous
|
||||
values
|
||||
precision (int): round filtered value to precision value
|
||||
entity (string): used for debugging only
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
name,
|
||||
window_size: int = 1,
|
||||
precision: Optional[int] = None,
|
||||
entity: Optional[str] = None,
|
||||
):
|
||||
"""Initialize common attributes.
|
||||
|
||||
def __init__(self, name, window_size=1, precision=None, entity=None):
|
||||
"""Initialize common attributes."""
|
||||
:param window_size: size of the sliding window that holds previous values
|
||||
:param precision: round filtered value to precision value
|
||||
:param entity: used for debugging only
|
||||
"""
|
||||
if isinstance(window_size, int):
|
||||
self.states = deque(maxlen=window_size)
|
||||
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.
|
||||
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):
|
||||
"""Initialize Filter."""
|
||||
def __init__(
|
||||
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)
|
||||
self._lower_bound = lower_bound
|
||||
self._upper_bound = upper_bound
|
||||
@ -441,13 +451,13 @@ class OutlierFilter(Filter):
|
||||
"""BASIC outlier filter.
|
||||
|
||||
Determines if new state is in a band around the median.
|
||||
|
||||
Args:
|
||||
radius (float): band radius
|
||||
"""
|
||||
|
||||
def __init__(self, window_size, precision, entity, radius):
|
||||
"""Initialize Filter."""
|
||||
def __init__(self, window_size, precision, entity, radius: float):
|
||||
"""Initialize Filter.
|
||||
|
||||
:param radius: band radius
|
||||
"""
|
||||
super().__init__(FILTER_NAME_OUTLIER, window_size, precision, entity)
|
||||
self._radius = radius
|
||||
self._stats_internal = Counter()
|
||||
@ -475,13 +485,9 @@ class OutlierFilter(Filter):
|
||||
|
||||
@FILTERS.register(FILTER_NAME_LOWPASS)
|
||||
class LowPassFilter(Filter):
|
||||
"""BASIC Low Pass Filter.
|
||||
"""BASIC Low Pass Filter."""
|
||||
|
||||
Args:
|
||||
time_constant (int): time constant.
|
||||
"""
|
||||
|
||||
def __init__(self, window_size, precision, entity, time_constant):
|
||||
def __init__(self, window_size, precision, entity, time_constant: int):
|
||||
"""Initialize Filter."""
|
||||
super().__init__(FILTER_NAME_LOWPASS, window_size, precision, entity)
|
||||
self._time_constant = time_constant
|
||||
@ -505,15 +511,15 @@ class TimeSMAFilter(Filter):
|
||||
"""Simple Moving Average (SMA) Filter.
|
||||
|
||||
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__(
|
||||
self, window_size, precision, entity, type
|
||||
): # 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)
|
||||
self._time_window = window_size
|
||||
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)
|
||||
update time: 1:36AM.
|
||||
|
||||
"""
|
||||
_LOGGER.debug("Scheduling next update for Islamic prayer times")
|
||||
|
||||
|
@ -55,9 +55,8 @@ class LW12WiFi(Light):
|
||||
def __init__(self, name, lw12_light):
|
||||
"""Initialise LW-12 WiFi LED Controller.
|
||||
|
||||
Args:
|
||||
name: Friendly name for this platform to use.
|
||||
lw12_light: Instance of the LW12 controller.
|
||||
:param name: Friendly name for this platform to use.
|
||||
:param lw12_light: Instance of the LW12 controller.
|
||||
"""
|
||||
self._light = lw12_light
|
||||
self._name = name
|
||||
|
@ -3,6 +3,7 @@ import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Callable, Optional, Union
|
||||
|
||||
import aiohttp
|
||||
import async_timeout
|
||||
@ -56,29 +57,25 @@ class WUSensorConfig:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
friendly_name,
|
||||
feature,
|
||||
value,
|
||||
unit_of_measurement=None,
|
||||
friendly_name: Union[str, Callable],
|
||||
feature: str,
|
||||
value: Callable[["WUndergroundData"], Any],
|
||||
unit_of_measurement: Optional[str] = None,
|
||||
entity_picture=None,
|
||||
icon="mdi:gauge",
|
||||
icon: str = "mdi:gauge",
|
||||
device_state_attributes=None,
|
||||
device_class=None,
|
||||
):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
friendly_name (string|func): Friendly name
|
||||
feature (string): WU feature. See:
|
||||
:param friendly_name: Friendly name
|
||||
:param feature: WU feature. See:
|
||||
https://www.wunderground.com/weather/api/d/docs?d=data/index
|
||||
value (function(WUndergroundData)): callback that
|
||||
extracts desired value from WUndergroundData object
|
||||
unit_of_measurement (string): unit of measurement
|
||||
entity_picture (string): value or callback returning
|
||||
URL of entity picture
|
||||
icon (string): icon name or URL
|
||||
device_state_attributes (dict): dictionary of attributes,
|
||||
or callable that returns it
|
||||
:param value: callback that extracts desired value from WUndergroundData object
|
||||
:param unit_of_measurement: unit of measurement
|
||||
:param entity_picture: value or callback returning URL of entity picture
|
||||
:param icon: icon name or URL
|
||||
:param device_state_attributes: dictionary of attributes, or callable that returns it
|
||||
"""
|
||||
self.friendly_name = friendly_name
|
||||
self.unit_of_measurement = unit_of_measurement
|
||||
@ -95,21 +92,18 @@ class WUCurrentConditionsSensorConfig(WUSensorConfig):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
friendly_name,
|
||||
field,
|
||||
icon="mdi:gauge",
|
||||
unit_of_measurement=None,
|
||||
friendly_name: Union[str, Callable],
|
||||
field: str,
|
||||
icon: Optional[str] = "mdi:gauge",
|
||||
unit_of_measurement: Optional[str] = None,
|
||||
device_class=None,
|
||||
):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
friendly_name (string|func): Friendly name of sensor
|
||||
field (string): Field name in the "current_observation"
|
||||
dictionary.
|
||||
icon (string): icon name or URL, if None sensor
|
||||
will use current weather symbol
|
||||
unit_of_measurement (string): unit of measurement
|
||||
:param friendly_name: Friendly name of sensor
|
||||
:field: Field name in the "current_observation" dictionary.
|
||||
:icon: icon name or URL, if None sensor will use current weather symbol
|
||||
:unit_of_measurement: unit of measurement
|
||||
"""
|
||||
super().__init__(
|
||||
friendly_name,
|
||||
@ -130,13 +124,14 @@ class WUCurrentConditionsSensorConfig(WUSensorConfig):
|
||||
class WUDailyTextForecastSensorConfig(WUSensorConfig):
|
||||
"""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.
|
||||
|
||||
Args:
|
||||
period (int): forecast period number
|
||||
field (string): field name to use as value
|
||||
unit_of_measurement(string): unit of measurement
|
||||
:param period: forecast period number
|
||||
:param field: field name to use as value
|
||||
:param unit_of_measurement: unit of measurement
|
||||
"""
|
||||
super().__init__(
|
||||
friendly_name=lambda wu: wu.data["forecast"]["txt_forecast"]["forecastday"][
|
||||
@ -161,24 +156,22 @@ class WUDailySimpleForecastSensorConfig(WUSensorConfig):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
friendly_name,
|
||||
period,
|
||||
field,
|
||||
wu_unit=None,
|
||||
ha_unit=None,
|
||||
friendly_name: str,
|
||||
period: int,
|
||||
field: str,
|
||||
wu_unit: Optional[str] = None,
|
||||
ha_unit: Optional[str] = None,
|
||||
icon=None,
|
||||
device_class=None,
|
||||
):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
period (int): forecast period number
|
||||
field (string): field name to use as value
|
||||
wu_unit (string): "fahrenheit", "celsius", "degrees" etc.
|
||||
see the example json at:
|
||||
https://www.wunderground.com/weather/api/d/docs?d=data/forecast&MR=1
|
||||
ha_unit (string): corresponding unit in home assistant
|
||||
title (string): friendly_name of the sensor
|
||||
:param friendly_name: friendly_name of the sensor
|
||||
:param period: forecast period number
|
||||
:param field: field name to use as value
|
||||
:param wu_unit: "fahrenheit", "celsius", "degrees" etc. see the example json at:
|
||||
https://www.wunderground.com/weather/api/d/docs?d=data/forecast&MR=1
|
||||
:param ha_unit: corresponding unit in home assistant
|
||||
"""
|
||||
super().__init__(
|
||||
friendly_name=friendly_name,
|
||||
@ -213,12 +206,11 @@ class WUDailySimpleForecastSensorConfig(WUSensorConfig):
|
||||
class WUHourlyForecastSensorConfig(WUSensorConfig):
|
||||
"""Helper for defining sensor configurations for hourly text forecasts."""
|
||||
|
||||
def __init__(self, period, field):
|
||||
def __init__(self, period: int, field: int):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
period (int): forecast period number
|
||||
field (int): field name to use as value
|
||||
:param period: forecast period number
|
||||
:param field: field name to use as value
|
||||
"""
|
||||
super().__init__(
|
||||
friendly_name=lambda wu: "{} {}".format(
|
||||
@ -274,24 +266,22 @@ class WUAlmanacSensorConfig(WUSensorConfig):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
friendly_name,
|
||||
field,
|
||||
value_type,
|
||||
wu_unit,
|
||||
unit_of_measurement,
|
||||
icon,
|
||||
friendly_name: Union[str, Callable],
|
||||
field: str,
|
||||
value_type: str,
|
||||
wu_unit: str,
|
||||
unit_of_measurement: str,
|
||||
icon: str,
|
||||
device_class=None,
|
||||
):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
friendly_name (string|func): Friendly name
|
||||
field (string): value name returned in 'almanac' dict
|
||||
as returned by the WU API
|
||||
value_type (string): "record" or "normal"
|
||||
wu_unit (string): unit name in WU API
|
||||
icon (string): icon name or URL
|
||||
unit_of_measurement (string): unit of measurement
|
||||
:param friendly_name: Friendly name
|
||||
:param field: value name returned in 'almanac' dict as returned by the WU API
|
||||
:param value_type: "record" or "normal"
|
||||
:param wu_unit: unit name in WU API
|
||||
:param unit_of_measurement: unit of measurement
|
||||
:param icon: icon name or URL
|
||||
"""
|
||||
super().__init__(
|
||||
friendly_name=friendly_name,
|
||||
@ -306,11 +296,10 @@ class WUAlmanacSensorConfig(WUSensorConfig):
|
||||
class WUAlertsSensorConfig(WUSensorConfig):
|
||||
"""Helper for defining field configuration for alerts."""
|
||||
|
||||
def __init__(self, friendly_name):
|
||||
def __init__(self, friendly_name: Union[str, Callable]):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
friendly_name (string|func): Friendly name
|
||||
:param friendly_name: Friendly name
|
||||
"""
|
||||
super().__init__(
|
||||
friendly_name=friendly_name,
|
||||
|
@ -40,6 +40,7 @@ def _include_yaml(
|
||||
|
||||
Example:
|
||||
device_tracker: !include device_tracker.yaml
|
||||
|
||||
"""
|
||||
if constructor.name is None:
|
||||
raise HomeAssistantError(
|
||||
|
@ -113,6 +113,7 @@ def _include_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE:
|
||||
|
||||
Example:
|
||||
device_tracker: !include device_tracker.yaml
|
||||
|
||||
"""
|
||||
fname = os.path.join(os.path.dirname(loader.name), node.value)
|
||||
return _add_reference(load_yaml(fname), loader, node)
|
||||
|
@ -7,11 +7,11 @@ asynctest==0.13.0
|
||||
black==19.3b0
|
||||
codecov==2.0.15
|
||||
coveralls==1.2.0
|
||||
flake8-docstrings==1.3.0
|
||||
flake8-docstrings==1.3.1
|
||||
flake8==3.7.8
|
||||
mock-open==1.3.1
|
||||
mypy==0.720
|
||||
pydocstyle==3.0.0
|
||||
pydocstyle==4.0.0
|
||||
pylint==2.3.1
|
||||
pytest-aiohttp==0.3.0
|
||||
pytest-cov==2.7.1
|
||||
|
@ -8,11 +8,11 @@ asynctest==0.13.0
|
||||
black==19.3b0
|
||||
codecov==2.0.15
|
||||
coveralls==1.2.0
|
||||
flake8-docstrings==1.3.0
|
||||
flake8-docstrings==1.3.1
|
||||
flake8==3.7.8
|
||||
mock-open==1.3.1
|
||||
mypy==0.720
|
||||
pydocstyle==3.0.0
|
||||
pydocstyle==4.0.0
|
||||
pylint==2.3.1
|
||||
pytest-aiohttp==0.3.0
|
||||
pytest-cov==2.7.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user