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

Commit bcdbd84

Browse files
authored
First batch code cleanup pylint (#23)
* First batch of code cleanup
1 parent 330f23f commit bcdbd84

File tree

10 files changed

+248
-264
lines changed

10 files changed

+248
-264
lines changed

.pylintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[MASTER]
2+
disable=
3+
C0114, # missing-module-docstring, ignore for now
4+
C0115, # missing-module-docstring, ignore for now
5+
C0116, # missing-function-docstring, ignore for now
6+
C0301, # line-too-long, ignore for now
7+
C0302, # too-many-lines, ignore for now
8+
W0511, # fixme, ignore for now

custom_components/victron/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import Callable
2-
from homeassistant.helpers.typing import StateType
3-
42
from dataclasses import dataclass
3+
4+
from homeassistant.helpers.typing import StateType
55
from homeassistant.helpers.entity import EntityDescription
66

77

custom_components/victron/binary_sensor.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
from typing import cast
66

7-
from homeassistant.core import HomeAssistant, HassJob
8-
9-
7+
import logging
108
from dataclasses import dataclass
119

10+
from homeassistant.core import HomeAssistant, HassJob
11+
1212
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1313

1414
from homeassistant.config_entries import ConfigEntry
@@ -25,7 +25,6 @@
2525
from .base import VictronBaseEntityDescription
2626
from .const import DOMAIN, register_info_dict, BoolReadEntityType
2727

28-
import logging
2928

3029
_LOGGER = logging.getLogger(__name__)
3130

@@ -45,24 +44,21 @@ async def async_setup_entry(
4544
descriptions = []
4645
# TODO cleanup
4746
register_set = victron_coordinator.processed_data()["register_set"]
48-
for slave, registerLedger in register_set.items():
49-
for name in registerLedger:
50-
for register_name, registerInfo in register_info_dict[name].items():
47+
for slave, register_ledger in register_set.items():
48+
for name in register_ledger:
49+
for register_name, register_info in register_info_dict[name].items():
5150
_LOGGER.debug(
52-
"unit == "
53-
+ str(slave)
54-
+ " registerLedger == "
55-
+ str(registerLedger)
56-
+ " registerInfo "
51+
"unit == $s register_ledger == %s registerInfo",
52+
{str(slave), str(register_ledger)},
5753
)
5854

59-
if isinstance(registerInfo.entityType, BoolReadEntityType):
55+
if isinstance(register_info.entityType, BoolReadEntityType):
6056
description = VictronEntityDescription(
6157
key=register_name,
6258
name=register_name.replace("_", " "),
6359
slave=slave,
6460
)
65-
_LOGGER.debug("composed description == " + str(description))
61+
_LOGGER.debug("composed description == %s", {str(description)})
6662
descriptions.append(description)
6763

6864
entities = []
@@ -127,6 +123,6 @@ def device_info(self) -> entity.DeviceInfo:
127123
return entity.DeviceInfo(
128124
identifiers={(DOMAIN, self.unique_id.split("_")[0])},
129125
name=self.unique_id.split("_")[1],
130-
model=self.unique_id.split("_")[0],
126+
model=self.unique_id.split("_", maxsplit=1)[0],
131127
manufacturer="victron",
132128
)

custom_components/victron/button.py

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

33
from __future__ import annotations
44

5-
from homeassistant.core import HomeAssistant, HassJob
6-
75
from dataclasses import dataclass
6+
import logging
7+
8+
from homeassistant.core import HomeAssistant, HassJob
89

910
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1011

@@ -23,7 +24,6 @@
2324
from .coordinator import victronEnergyDeviceUpdateCoordinator
2425
from .const import DOMAIN, CONF_ADVANCED_OPTIONS, register_info_dict, ButtonWriteType
2526

26-
import logging
2727

2828
_LOGGER = logging.getLogger(__name__)
2929

@@ -45,11 +45,8 @@ async def async_setup_entry(
4545
for name in registerLedger:
4646
for register_name, registerInfo in register_info_dict[name].items():
4747
_LOGGER.debug(
48-
"unit == "
49-
+ str(slave)
50-
+ " registerLedger == "
51-
+ str(registerLedger)
52-
+ " registerInfo "
48+
"unit == $s register_ledger == %s registerInfo",
49+
{str(slave), str(registerLedger)},
5350
)
5451
if not config_entry.options[CONF_ADVANCED_OPTIONS]:
5552
continue
@@ -62,7 +59,7 @@ async def async_setup_entry(
6259
device_class=ButtonDeviceClass.RESTART,
6360
address=registerInfo.register,
6461
)
65-
_LOGGER.debug("composed description == " + str(description))
62+
_LOGGER.debug("composed description == %s", {str(description)})
6663
descriptions.append(description)
6764

6865
entities = []

custom_components/victron/config_flow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import voluptuous as vol
99

10-
1110
from homeassistant import config_entries
1211
from homeassistant.core import HomeAssistant
1312
from homeassistant.data_entry_flow import FlowResult

0 commit comments

Comments
 (0)