mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use pylint disable-next in MQTT (#66758)
This commit is contained in:
parent
9d5dc2ce24
commit
750b48dcaf
@ -895,7 +895,7 @@ class MQTT:
|
|||||||
|
|
||||||
async def async_connect(self) -> None:
|
async def async_connect(self) -> None:
|
||||||
"""Connect to the host. Does not process messages yet."""
|
"""Connect to the host. Does not process messages yet."""
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
result: int | None = None
|
result: int | None = None
|
||||||
@ -1000,7 +1000,7 @@ class MQTT:
|
|||||||
Resubscribe to all topics we were subscribed to and publish birth
|
Resubscribe to all topics we were subscribed to and publish birth
|
||||||
message.
|
message.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
if result_code != mqtt.CONNACK_ACCEPTED:
|
if result_code != mqtt.CONNACK_ACCEPTED:
|
||||||
@ -1159,7 +1159,7 @@ class MQTT:
|
|||||||
|
|
||||||
def _raise_on_error(result_code: int | None) -> None:
|
def _raise_on_error(result_code: int | None) -> None:
|
||||||
"""Raise error if error result."""
|
"""Raise error if error result."""
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
if result_code is not None and result_code != 0:
|
if result_code is not None and result_code != 0:
|
||||||
@ -1169,7 +1169,7 @@ def _raise_on_error(result_code: int | None) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _matcher_for_topic(subscription: str) -> Any:
|
def _matcher_for_topic(subscription: str) -> Any:
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
from paho.mqtt.matcher import MQTTMatcher
|
from paho.mqtt.matcher import MQTTMatcher
|
||||||
|
|
||||||
matcher = MQTTMatcher()
|
matcher = MQTTMatcher()
|
||||||
|
@ -313,7 +313,7 @@ class MQTTOptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
|
|
||||||
def try_connection(broker, port, username, password, protocol="3.1"):
|
def try_connection(broker, port, username, password, protocol="3.1"):
|
||||||
"""Test if we can connect to an MQTT broker."""
|
"""Test if we can connect to an MQTT broker."""
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
if protocol == "3.1":
|
if protocol == "3.1":
|
||||||
|
@ -228,13 +228,13 @@ async def async_start( # noqa: C901
|
|||||||
if config_entries_key not in hass.data[CONFIG_ENTRY_IS_SETUP]:
|
if config_entries_key not in hass.data[CONFIG_ENTRY_IS_SETUP]:
|
||||||
if component == "device_automation":
|
if component == "device_automation":
|
||||||
# Local import to avoid circular dependencies
|
# Local import to avoid circular dependencies
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
from . import device_automation
|
from . import device_automation
|
||||||
|
|
||||||
await device_automation.async_setup_entry(hass, config_entry)
|
await device_automation.async_setup_entry(hass, config_entry)
|
||||||
elif component == "tag":
|
elif component == "tag":
|
||||||
# Local import to avoid circular dependencies
|
# Local import to avoid circular dependencies
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
from . import tag
|
from . import tag
|
||||||
|
|
||||||
await tag.async_setup_entry(hass, config_entry)
|
await tag.async_setup_entry(hass, config_entry)
|
||||||
|
@ -420,10 +420,7 @@ class MqttAvailability(Entity):
|
|||||||
CONF_AVAILABILITY_TEMPLATE: avail.get(CONF_VALUE_TEMPLATE),
|
CONF_AVAILABILITY_TEMPLATE: avail.get(CONF_VALUE_TEMPLATE),
|
||||||
}
|
}
|
||||||
|
|
||||||
for (
|
for avail_topic_conf in self._avail_topics.values():
|
||||||
topic, # pylint: disable=unused-variable
|
|
||||||
avail_topic_conf,
|
|
||||||
) in self._avail_topics.items():
|
|
||||||
avail_topic_conf[CONF_AVAILABILITY_TEMPLATE] = MqttValueTemplate(
|
avail_topic_conf[CONF_AVAILABILITY_TEMPLATE] = MqttValueTemplate(
|
||||||
avail_topic_conf[CONF_AVAILABILITY_TEMPLATE],
|
avail_topic_conf[CONF_AVAILABILITY_TEMPLATE],
|
||||||
entity=self,
|
entity=self,
|
||||||
@ -502,7 +499,7 @@ class MqttAvailability(Entity):
|
|||||||
async def cleanup_device_registry(hass, device_id):
|
async def cleanup_device_registry(hass, device_id):
|
||||||
"""Remove device registry entry if there are no remaining entities or triggers."""
|
"""Remove device registry entry if there are no remaining entities or triggers."""
|
||||||
# Local import to avoid circular dependencies
|
# Local import to avoid circular dependencies
|
||||||
# pylint: disable=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
from . import device_trigger, tag
|
from . import device_trigger, tag
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user