Skip to content

Commit 414afd2

Browse files
committed
WIP refactor: fix linter errors
1 parent 8117772 commit 414afd2

File tree

9 files changed

+353
-418
lines changed

9 files changed

+353
-418
lines changed

.github/scripts/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Module of scripts."""

.github/scripts/update_hacs_manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77

8-
def update_manifest():
8+
def update_manifest() -> None:
99
"""Update the manifest file."""
1010
version = "0.0.0"
1111
for index, value in enumerate(sys.argv):

custom_components/dijnet/__init__.py

+28-24
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,39 @@
1616

1717
_LOGGER = logging.getLogger(__name__)
1818

19-
# pylint: disable=unused-argument
2019

21-
22-
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
20+
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: # noqa: ARG001
2321
"""
24-
Set up the Dijnet component.
22+
Sets up the Dijnet component.
2523
26-
Parameters
27-
----------
28-
hass: homeassistant.helpers.typing.HomeAssistantType
24+
Args:
25+
hass:
2926
The Home Assistant instance.
30-
config: homeassistant.helpers.typing.ConfigType
27+
config:
3128
The configuration.
3229
33-
Returns
34-
-------
35-
bool
36-
The value indicates whether the setup succeeded.
30+
Returns:
31+
The value indicates whether the setup succeeded.
32+
3733
"""
3834
hass.data[DOMAIN] = {DATA_CONTROLLER: {}}
3935
return True
4036

4137

4238
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
4339
"""
44-
Initialize the sensors based on the config entry.
40+
Initializes the sensors based on the config entry.
4541
46-
Parameters
47-
----------
48-
hass: homeassistant.helpers.typing.HomeAssistantType
42+
Args:
43+
hass:
4944
The Home Assistant instance.
50-
config_entry: homeassistant.config_entries.ConfigEntry
45+
config_entry:
5146
The config entry which contains information gathered by the config flow.
5247
53-
Returns
54-
-------
55-
bool
56-
The value indicates whether the setup succeeded.
57-
"""
48+
Returns:
49+
The value indicates whether the setup succeeded.
5850
51+
"""
5952
if not is_controller_exists(hass, config_entry.data[CONF_USERNAME]):
6053
set_controller(
6154
hass,
@@ -73,8 +66,19 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry)
7366
return True
7467

7568

76-
async def async_migrate_entry(hass: HomeAssistantType, config_entry: ConfigEntry):
77-
"""Migrate old entry."""
69+
async def async_migrate_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
70+
"""
71+
Migrates old entry.
72+
73+
Args:
74+
hass:
75+
The Home Assistant instance.
76+
config_entry:
77+
The config entry to migrate.
78+
79+
Returns:
80+
The value indicates whether the migration succeeded.
81+
"""
7882
_LOGGER.debug("Migrating from version %s", config_entry.version)
7983

8084
if config_entry.version == 1:

custom_components/dijnet/config_flow.py

+26-31
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# pylint: disable=bad-continuation
2-
"""
3-
The configuration flow module for Dijnet integration.
4-
"""
1+
"""The configuration flow module for Dijnet integration."""
52

63
import logging
7-
from typing import Any, Dict
4+
from typing import Any, Self
85

96
import voluptuous as vol
107
from homeassistant.config_entries import HANDLERS, ConfigEntry, ConfigFlow, OptionsFlow
@@ -21,30 +18,26 @@
2118
class DijnetOptionsFlowHandler(OptionsFlow):
2219
"""Handle Dijnet options."""
2320

24-
def __init__(self, config_entry: ConfigEntry) -> None:
21+
def __init__(self: Self, config_entry: ConfigEntry) -> None:
2522
"""
2623
Initialize a new instance of DijnetOptionsFlowHandler class.
2724
28-
Parameters
29-
----------
30-
config_entry: homeassistant.config_entries.ConfigEntry
25+
Args:
26+
config_entry:
3127
The config entry of the integration.
3228
33-
Returns
34-
-------
35-
None
3629
"""
3730
self.config_entry = config_entry
3831

39-
async def async_step_init(self, user_input: Dict[str, Any] = None) -> FlowResult:
32+
async def async_step_init(self: Self, user_input: dict[str, Any] | None = None) -> FlowResult:
4033
"""
4134
Handles Dijnet configuration init step.
4235
43-
Parameters
44-
----------
45-
user_input: Dict[str, Any]
36+
Args:
37+
user_input:
4638
The dictionary contains the settings entered by the user
4739
on the configuration screen.
40+
4841
"""
4942
data_schema = vol.Schema(
5043
{
@@ -81,9 +74,7 @@ async def async_step_init(self, user_input: Dict[str, Any] = None) -> FlowResult
8174

8275
@HANDLERS.register(DOMAIN)
8376
class DijnetConfigFlow(ConfigFlow, domain=DOMAIN):
84-
"""
85-
Configuration flow handler for Dijnet integration.
86-
"""
77+
"""Configuration flow handler for Dijnet integration."""
8778

8879
VERSION = 2
8980

@@ -93,21 +84,27 @@ def async_get_options_flow(config_entry: ConfigFlow) -> DijnetOptionsFlowHandler
9384
"""
9485
Gets the options flow handler for the integration.
9586
96-
Parameters
97-
----------
98-
config_entry: homeassistant.config_entries.ConfigEntry
87+
Args:
88+
config_entry:
9989
The config entry of the integration.
10090
101-
Returns
102-
-------
103-
DijnetOptionsFlowHandler
104-
The options flow handler for the integration.
91+
Returns:
92+
The options flow handler for the integration.
93+
10594
"""
10695
return DijnetOptionsFlowHandler(config_entry)
10796

108-
async def async_step_user(self, user_input: Dict[str, Any]) -> FlowResult:
97+
async def async_step_user(self: Self, user_input: dict[str, Any]) -> FlowResult:
10998
"""
11099
Handles the step when integration added from the UI.
100+
101+
Args:
102+
user_input:
103+
The dictionary contains the settings entered by the user
104+
on the configuration screen.
105+
106+
Returns:
107+
The result of the flow step.
111108
"""
112109
data_schema = vol.Schema(
113110
{
@@ -148,10 +145,8 @@ async def async_step_user(self, user_input: Dict[str, Any]) -> FlowResult:
148145
data_schema=data_schema,
149146
)
150147

151-
async def async_step_import(self, import_config: Dict[str, Any]) -> FlowResult:
152-
"""
153-
Handles the yaml configuration import step.
154-
"""
148+
async def async_step_import(self: Self, import_config: dict[str, Any]) -> FlowResult:
149+
"""Handles the yaml configuration import step."""
155150
_LOGGER.debug("Importing Dijnet config from yaml.")
156151

157152
await self.async_set_unique_id(import_config[CONF_USERNAME])

custom_components/dijnet/const.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Constants for Dijnet integration.
3-
"""
1+
"""Constants for Dijnet integration."""
42

53
DOMAIN = "dijnet"
64

0 commit comments

Comments
 (0)