From dcdbfbce77faf2b8d0a586018aec5ce6143cf501 Mon Sep 17 00:00:00 2001 From: Maikel Punie Date: Fri, 2 Feb 2024 15:32:27 +0100 Subject: [PATCH] Make ci pass again --- .pre-commit-config.yaml | 1 + duotecno/controller.py | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6021551..aaf54a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,7 @@ repos: - id: codespell args: - --quiet-level=2 + - --ignore-words-list=hass - repo: https://github.com/PyCQA/bandit rev: 1.7.5 hooks: diff --git a/duotecno/controller.py b/duotecno/controller.py index 4d1a76a..e8351a0 100644 --- a/duotecno/controller.py +++ b/duotecno/controller.py @@ -1,7 +1,6 @@ """Main interface to the duotecno bus.""" from __future__ import annotations import asyncio -import socket import logging from collections import deque from duotecno.exceptions import LoadFailure, InvalidPassword @@ -14,9 +13,7 @@ ) from duotecno.node import Node from duotecno.unit import BaseUnit -from homeassistant.config_entries import ConfigEntries -from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant + class PyDuotecno: """Class that will will do the bus management. @@ -44,9 +41,10 @@ def __init__(self, hass): async def reload_integration(self): self._log.debug("Reload the Duotecno integration.") # Get all Duotecno config entries - entries = self.hass.config_entries.async_entries('duotecno') + entries = self.hass.config_entries.async_entries("duotecno") - # You may want to handle the case where the integration to reload has multiple entries (modules). + # You may want to handle the case where the integration + # to reload has multiple entries (modules). for entry in entries: # Reload the integration await self.hass.config_entries.async_reload(entry.entry_id) @@ -127,8 +125,8 @@ async def write(self, msg: str) -> None: if not self.writer: return if self.writer.transport.is_closing(): - #await self.disconnect() - #await self._do_connect() + # await self.disconnect() + # await self._do_connect() return self._log.debug(f"Send: {msg}") msg = f"{msg}{chr(10)}" @@ -136,8 +134,8 @@ async def write(self, msg: str) -> None: self.writer.write(msg.encode()) await self.writer.drain() except ConnectionError: - #await self.disconnect() - #await self._do_connect() + # await self.disconnect() + # await self._do_connect() return async def _loadTask(self) -> None: @@ -192,7 +190,6 @@ async def heartbeatTask(self) -> None: self._log.warning("Timeout on heartbeat, reconnecting") await self.disconnect() await self.continuously_check_connection() - break except asyncio.exceptions.CancelledError: break @@ -205,10 +202,9 @@ async def readTask(self) -> None: try: tmp2 = await self.reader.readline() except ConnectionError: - #await self.disconnect() - #await self._do_connect() + # await self.disconnect() + # await self._do_connect() return - if tmp2 == "": return tmp3 = tmp2.decode() @@ -263,4 +259,4 @@ async def _handlePacket(self, packet: Packet) -> None: if hasattr(packet.cls, "address") and packet.cls.address in self.nodes: await self.nodes[packet.cls.address].handlePacket(packet.cls) return - self._log.debug(f"Ignoring packet: {packet}") \ No newline at end of file + self._log.debug(f"Ignoring packet: {packet}")