Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 98dc4bf

Browse files
committed
Add ruff fixes
1 parent 0a985f2 commit 98dc4bf

File tree

10 files changed

+10
-31
lines changed

10 files changed

+10
-31
lines changed

custom_components/victron/binary_sensor.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22

33
from __future__ import annotations
44

5-
from contextlib import suppress
65
from typing import cast
76

87
from homeassistant.core import HomeAssistant, HassJob
98

10-
from collections.abc import Callable
11-
from homeassistant.helpers.typing import StateType
129

1310
from dataclasses import dataclass
1411

1512
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1613

1714
from homeassistant.config_entries import ConfigEntry
18-
from homeassistant.core import HomeAssistant
1915
from homeassistant.helpers.entity_platform import AddEntitiesCallback
20-
from homeassistant.helpers import event, entity
16+
from homeassistant.helpers import entity
2117

2218
from homeassistant.components.binary_sensor import (
2319
BinarySensorEntityDescription,
@@ -27,7 +23,7 @@
2723

2824
from .coordinator import victronEnergyDeviceUpdateCoordinator
2925
from .base import VictronBaseEntityDescription
30-
from .const import DOMAIN, CONF_ADVANCED_OPTIONS, register_info_dict, BoolReadEntityType
26+
from .const import DOMAIN, register_info_dict, BoolReadEntityType
3127

3228
import logging
3329

custom_components/victron/button.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1010

1111
from homeassistant.config_entries import ConfigEntry
12-
from homeassistant.core import HomeAssistant
1312
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1413
from homeassistant.helpers import entity
1514

custom_components/victron/config_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from homeassistant.core import callback
2323

24-
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
24+
from homeassistant.config_entries import ConfigEntry
2525

2626
from .const import (
2727
DOMAIN,
@@ -129,7 +129,7 @@ async def async_step_user(
129129
# not yet working
130130
await self.async_set_unique_id("victron")
131131
self._abort_if_unique_id_configured()
132-
except Exception as e:
132+
except Exception:
133133
errors["base"] = "already_configured"
134134
already_configured = True
135135

custom_components/victron/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from enum import Enum
44
from homeassistant.const import (
55
PERCENTAGE,
6-
UnitOfPower,
76
UnitOfEnergy,
87
UnitOfElectricPotential,
98
UnitOfElectricCurrent,

custom_components/victron/coordinator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from pymodbus.constants import Endian
1313
from pymodbus.payload import BinaryPayloadDecoder
14-
from pymodbus.pdu import register_read_message
14+
from pymodbus.pdu.register_message import ReadHoldingRegistersResponse
1515

1616
from datetime import timedelta
1717

@@ -106,7 +106,7 @@ async def _async_update_data(self) -> dict:
106106
def parse_register_data(
107107
self,
108108
buffer: ReadHoldingRegistersResponse,
109-
registerInfo: OrderedDict(str, RegisterInfo),
109+
registerInfo: OrderedDict[str, RegisterInfo],
110110
unit: int,
111111
) -> dict:
112112
decoder = BinaryPayloadDecoder.fromRegisters(
@@ -184,7 +184,7 @@ async def fetch_registers(self, unit, registerData):
184184
def write_register(self, unit, address, value):
185185
# try:
186186

187-
resp = self.api_write(unit, address, value)
187+
self.api_write(unit, address, value)
188188

189189
# except:
190190
# TODO raise specific write error

custom_components/victron/hub.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from pymodbus.client import ModbusTcpClient
2-
from pymodbus.exceptions import ModbusException
32

43
import threading
54
from collections import OrderedDict

custom_components/victron/number.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Callable
65
from dataclasses import dataclass
7-
from typing import Optional, cast
86

97
from homeassistant import config_entries
108
from homeassistant.components.number import (
@@ -19,15 +17,12 @@
1917
UnitOfElectricPotential,
2018
UnitOfPower,
2119
UnitOfElectricCurrent,
22-
UnitOfTime,
2320
)
2421

25-
import math
2622

27-
from homeassistant.core import HomeAssistant, callback
23+
from homeassistant.core import HomeAssistant
2824
from homeassistant.helpers.entity import EntityCategory
2925
from homeassistant.helpers.entity_platform import AddEntitiesCallback
30-
from homeassistant.helpers.update_coordinator import CoordinatorEntity
3126

3227
from .coordinator import victronEnergyDeviceUpdateCoordinator
3328
from .base import VictronWriteBaseEntityDescription
@@ -45,7 +40,6 @@
4540
CONF_AC_CURRENT_LIMIT,
4641
)
4742

48-
from homeassistant.helpers.typing import StateType
4943
from homeassistant.helpers import entity
5044

5145
import logging

custom_components/victron/select.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
from .const import DOMAIN, register_info_dict, SelectWriteType, CONF_ADVANCED_OPTIONS
2323
from .base import VictronWriteBaseEntityDescription
2424

25-
from collections.abc import Callable
26-
from homeassistant.helpers.typing import StateType
2725

2826
from datetime import timedelta
2927
from homeassistant.util import utcnow
30-
from homeassistant.helpers import event, entity
28+
from homeassistant.helpers import event
3129

3230
import logging
3331

custom_components/victron/sensor.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
import logging
66

7-
from datetime import timedelta
8-
from homeassistant.util import utcnow
9-
from homeassistant.helpers import event, entity
7+
from homeassistant.helpers import entity
108
from homeassistant.core import HomeAssistant, HassJob, callback
119
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1210
from homeassistant.helpers.update_coordinator import CoordinatorEntity
@@ -43,8 +41,6 @@
4341
UnitOfPressure,
4442
)
4543

46-
from collections.abc import Callable
47-
from homeassistant.helpers.typing import StateType
4844

4945
_LOGGER = logging.getLogger(__name__)
5046

custom_components/victron/switch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
from .const import DOMAIN, register_info_dict, SwitchWriteType, CONF_ADVANCED_OPTIONS
2323
from .base import VictronWriteBaseEntityDescription
2424

25-
from collections.abc import Callable
26-
from homeassistant.helpers.typing import StateType
2725

2826
import logging
2927

0 commit comments

Comments
 (0)