Enable basic type checking for azure_event_hub (#55047)
* Enable basic type checking for azure_event_hub * Update homeassistant/components/azure_event_hub/__init__.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Disable false pylint positive Co-authored-by: Martin Hjelmare <marhje52@gmail.com>pull/55093/head
parent
b76e8c5722
commit
68f1c19049
|
@ -5,9 +5,9 @@ import asyncio
|
|||
import json
|
||||
import logging
|
||||
import time
|
||||
from typing import Any
|
||||
from typing import Any, Callable
|
||||
|
||||
from azure.eventhub import EventData
|
||||
from azure.eventhub import EventData, EventDataBatch
|
||||
from azure.eventhub.aio import EventHubProducerClient, EventHubSharedKeyCredential
|
||||
from azure.eventhub.exceptions import EventHubError
|
||||
import voluptuous as vol
|
||||
|
@ -109,14 +109,16 @@ class AzureEventHub:
|
|||
) -> None:
|
||||
"""Initialize the listener."""
|
||||
self.hass = hass
|
||||
self.queue = asyncio.PriorityQueue()
|
||||
self.queue: asyncio.PriorityQueue[ # pylint: disable=unsubscriptable-object
|
||||
tuple[int, tuple[float, Event | None]]
|
||||
] = asyncio.PriorityQueue()
|
||||
self._client_args = client_args
|
||||
self._conn_str_client = conn_str_client
|
||||
self._entities_filter = entities_filter
|
||||
self._send_interval = send_interval
|
||||
self._max_delay = max_delay + send_interval
|
||||
self._listener_remover = None
|
||||
self._next_send_remover = None
|
||||
self._listener_remover: Callable[[], None] | None = None
|
||||
self._next_send_remover: Callable[[], None] | None = None
|
||||
self.shutdown = False
|
||||
|
||||
async def async_start(self) -> None:
|
||||
|
@ -169,7 +171,7 @@ class AzureEventHub:
|
|||
self.hass, self._send_interval, self.async_send
|
||||
)
|
||||
|
||||
async def fill_batch(self, client) -> None:
|
||||
async def fill_batch(self, client) -> tuple[EventDataBatch, int]:
|
||||
"""Return a batch of events formatted for writing.
|
||||
|
||||
Uses get_nowait instead of await get, because the functions batches and doesn't wait for each single event, the send function is called.
|
||||
|
@ -207,7 +209,7 @@ class AzureEventHub:
|
|||
|
||||
return event_batch, dequeue_count
|
||||
|
||||
def _event_to_filtered_event_data(self, event: Event) -> None:
|
||||
def _event_to_filtered_event_data(self, event: Event) -> EventData | None:
|
||||
"""Filter event states and create EventData object."""
|
||||
state = event.data.get("new_state")
|
||||
if (
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
"""Constants and shared schema for the Azure Event Hub integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
DOMAIN = "azure_event_hub"
|
||||
|
||||
CONF_EVENT_HUB_NAMESPACE = "event_hub_namespace"
|
||||
|
@ -10,4 +14,4 @@ CONF_SEND_INTERVAL = "send_interval"
|
|||
CONF_MAX_DELAY = "max_delay"
|
||||
CONF_FILTER = "filter"
|
||||
|
||||
ADDITIONAL_ARGS = {"logging_enable": False}
|
||||
ADDITIONAL_ARGS: dict[str, Any] = {"logging_enable": False}
|
||||
|
|
3
mypy.ini
3
mypy.ini
|
@ -1268,9 +1268,6 @@ warn_unreachable = false
|
|||
[mypy-homeassistant.components.awair.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.azure_event_hub.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.blueprint.*]
|
||||
ignore_errors = true
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ from .model import Config, Integration
|
|||
# Do your best to not add anything new here.
|
||||
IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.awair.*",
|
||||
"homeassistant.components.azure_event_hub.*",
|
||||
"homeassistant.components.blueprint.*",
|
||||
"homeassistant.components.bmw_connected_drive.*",
|
||||
"homeassistant.components.cert_expiry.*",
|
||||
|
|
Loading…
Reference in New Issue