Enable strict typing for alpha_vantage (#106816)
parent
4e0c0cf2ca
commit
0077989169
|
@ -58,6 +58,7 @@ homeassistant.components.aladdin_connect.*
|
|||
homeassistant.components.alarm_control_panel.*
|
||||
homeassistant.components.alert.*
|
||||
homeassistant.components.alexa.*
|
||||
homeassistant.components.alpha_vantage.*
|
||||
homeassistant.components.amazon_polly.*
|
||||
homeassistant.components.ambient_station.*
|
||||
homeassistant.components.amcrest.*
|
||||
|
|
|
@ -74,9 +74,9 @@ def setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Alpha Vantage sensor."""
|
||||
api_key = config[CONF_API_KEY]
|
||||
symbols = config.get(CONF_SYMBOLS, [])
|
||||
conversions = config.get(CONF_FOREIGN_EXCHANGE, [])
|
||||
api_key: str = config[CONF_API_KEY]
|
||||
symbols: list[dict[str, str]] = config.get(CONF_SYMBOLS, [])
|
||||
conversions: list[dict[str, str]] = config.get(CONF_FOREIGN_EXCHANGE, [])
|
||||
|
||||
if not symbols and not conversions:
|
||||
msg = "No symbols or currencies configured."
|
||||
|
@ -120,7 +120,7 @@ class AlphaVantageSensor(SensorEntity):
|
|||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(self, timeseries, symbol):
|
||||
def __init__(self, timeseries: TimeSeries, symbol: dict[str, str]) -> None:
|
||||
"""Initialize the sensor."""
|
||||
self._symbol = symbol[CONF_SYMBOL]
|
||||
self._attr_name = symbol.get(CONF_NAME, self._symbol)
|
||||
|
@ -154,7 +154,9 @@ class AlphaVantageForeignExchange(SensorEntity):
|
|||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(self, foreign_exchange, config):
|
||||
def __init__(
|
||||
self, foreign_exchange: ForeignExchange, config: dict[str, str]
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
self._foreign_exchange = foreign_exchange
|
||||
self._from_currency = config[CONF_FROM]
|
||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -340,6 +340,16 @@ disallow_untyped_defs = true
|
|||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.alpha_vantage.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.amazon_polly.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
|
Loading…
Reference in New Issue