mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Remove influxdb from mypy ignore list (#74612)
This commit is contained in:
parent
dc0c41982f
commit
bd43f0393c
@ -30,7 +30,7 @@ from homeassistant.const import (
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, State, callback
|
||||
from homeassistant.helpers import event as event_helper, state as state_helper
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_values import EntityValues
|
||||
@ -198,13 +198,13 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
def _generate_event_to_json(conf: dict) -> Callable[[dict], str]:
|
||||
def _generate_event_to_json(conf: dict) -> Callable[[Event], dict[str, Any] | None]:
|
||||
"""Build event to json converter and add to config."""
|
||||
entity_filter = convert_include_exclude_filter(conf)
|
||||
tags = conf.get(CONF_TAGS)
|
||||
tags_attributes = conf.get(CONF_TAGS_ATTRIBUTES)
|
||||
tags_attributes: list[str] = conf[CONF_TAGS_ATTRIBUTES]
|
||||
default_measurement = conf.get(CONF_DEFAULT_MEASUREMENT)
|
||||
measurement_attr = conf.get(CONF_MEASUREMENT_ATTR)
|
||||
measurement_attr: str = conf[CONF_MEASUREMENT_ATTR]
|
||||
override_measurement = conf.get(CONF_OVERRIDE_MEASUREMENT)
|
||||
global_ignore_attributes = set(conf[CONF_IGNORE_ATTRIBUTES])
|
||||
component_config = EntityValues(
|
||||
@ -213,15 +213,15 @@ def _generate_event_to_json(conf: dict) -> Callable[[dict], str]:
|
||||
conf[CONF_COMPONENT_CONFIG_GLOB],
|
||||
)
|
||||
|
||||
def event_to_json(event: dict) -> str:
|
||||
def event_to_json(event: Event) -> dict[str, Any] | None:
|
||||
"""Convert event into json in format Influx expects."""
|
||||
state = event.data.get(EVENT_NEW_STATE)
|
||||
state: State | None = event.data.get(EVENT_NEW_STATE)
|
||||
if (
|
||||
state is None
|
||||
or state.state in (STATE_UNKNOWN, "", STATE_UNAVAILABLE)
|
||||
or not entity_filter(state.entity_id)
|
||||
):
|
||||
return
|
||||
return None
|
||||
|
||||
try:
|
||||
_include_state = _include_value = False
|
||||
@ -263,7 +263,7 @@ def _generate_event_to_json(conf: dict) -> Callable[[dict], str]:
|
||||
else:
|
||||
include_uom = measurement_attr != "unit_of_measurement"
|
||||
|
||||
json = {
|
||||
json: dict[str, Any] = {
|
||||
INFLUX_CONF_MEASUREMENT: measurement,
|
||||
INFLUX_CONF_TAGS: {
|
||||
CONF_DOMAIN: state.domain,
|
||||
@ -328,7 +328,9 @@ class InfluxClient:
|
||||
close: Callable[[], None]
|
||||
|
||||
|
||||
def get_influx_connection(conf, test_write=False, test_read=False): # noqa: C901
|
||||
def get_influx_connection( # noqa: C901
|
||||
conf, test_write=False, test_read=False
|
||||
) -> InfluxClient:
|
||||
"""Create the correct influx connection for the API version."""
|
||||
kwargs = {
|
||||
CONF_TIMEOUT: TIMEOUT,
|
||||
@ -470,6 +472,10 @@ def get_influx_connection(conf, test_write=False, test_read=False): # noqa: C90
|
||||
return InfluxClient(databases, write_v1, query_v1, close_v1)
|
||||
|
||||
|
||||
def _retry_setup(hass: HomeAssistant, config: ConfigType) -> None:
|
||||
setup(hass, config)
|
||||
|
||||
|
||||
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the InfluxDB component."""
|
||||
conf = config[DOMAIN]
|
||||
@ -477,7 +483,9 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
influx = get_influx_connection(conf, test_write=True)
|
||||
except ConnectionError as exc:
|
||||
_LOGGER.error(RETRY_MESSAGE, exc)
|
||||
event_helper.call_later(hass, RETRY_INTERVAL, lambda _: setup(hass, config))
|
||||
event_helper.call_later(
|
||||
hass, RETRY_INTERVAL, lambda _: _retry_setup(hass, config)
|
||||
)
|
||||
return True
|
||||
|
||||
event_to_json = _generate_event_to_json(conf)
|
||||
|
3
mypy.ini
3
mypy.ini
@ -2665,9 +2665,6 @@ ignore_errors = true
|
||||
[mypy-homeassistant.components.icloud.sensor]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.influxdb]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.izone.climate]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -30,7 +30,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.icloud.account",
|
||||
"homeassistant.components.icloud.device_tracker",
|
||||
"homeassistant.components.icloud.sensor",
|
||||
"homeassistant.components.influxdb",
|
||||
"homeassistant.components.izone.climate",
|
||||
"homeassistant.components.konnected",
|
||||
"homeassistant.components.konnected.config_flow",
|
||||
|
Loading…
x
Reference in New Issue
Block a user