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

Commit 15e2425

Browse files
committed
fix(lint): mostly type hints
1 parent c51a477 commit 15e2425

File tree

8 files changed

+175
-153
lines changed

8 files changed

+175
-153
lines changed

poetry.lock

+122-105
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+30-29
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,18 @@ classifiers = [
88
"Environment :: Console",
99
"Operating System :: MacOS",
1010
"Operating System :: POSIX :: Linux",
11-
"Programming Language :: Python :: 3.8",
1211
"Programming Language :: Python :: 3.9",
1312
"Programming Language :: Python :: 3.10",
13+
"Programming Language :: Python :: 3.11",
14+
"Programming Language :: Python :: 3.12",
1415
"Topic :: System :: Logging",
1516
"Topic :: System :: Monitoring",
1617
]
1718
description = "Monitor your Philips Hue network"
1819
documentation = "https://github.com/edeckers/huemon"
1920
homepage = "https://github.com/edeckers/huemon"
20-
include = [
21-
"LICENSE",
22-
]
23-
keywords = [
24-
"Hue",
25-
"Monitoring",
26-
"Zabbix",
27-
"Zigbee",
28-
]
21+
include = ["LICENSE"]
22+
keywords = ["Hue", "Monitoring", "Zabbix", "Zigbee"]
2923
license = "MPL-2.0"
3024
maintainers = ["Ely Deckers"]
3125
name = "huemon"
@@ -35,7 +29,7 @@ version = "2.0.4"
3529

3630
[tool.poetry.dependencies]
3731
fastapi = "^0.115.6"
38-
pyella = "^2.0.0"
32+
pyella = "^3.1.0"
3933
python = "^3.9"
4034
PyYAML = "^6.0"
4135
types-PyYAML = "^6.0.4"
@@ -44,7 +38,7 @@ uvicorn = "^0.17.5"
4438
[tool.poetry.dev-dependencies]
4539
black = "^24.10.0"
4640
bandit = "^1.7"
47-
coverage = {extras = ["toml"], version = "^6.3.2"}
41+
coverage = { extras = ["toml"], version = "^6.3.2" }
4842
isort = "^5.12.0"
4943
mypy = "^1.0.0"
5044
nox = "^2022.1.7"
@@ -54,10 +48,6 @@ pytest = "^7"
5448
pytest-cov = "^4"
5549
python-semantic-release = "^8.0.8"
5650

57-
#########################################################################################
58-
# Testing
59-
#########################################################################################
60-
6151
[tool.pytest.ini_options]
6252
log_cli = true
6353
log_cli_level = "INFO"
@@ -74,26 +64,37 @@ directory = "reports/coverage/html"
7464
[tool.coverage.xml]
7565
output = "reports/coverage/coverage.xml"
7666

77-
#########################################################################################
78-
# Style checking
79-
#########################################################################################
67+
[tool.semantic_release]
68+
build_command = "poetry build"
69+
commit_message = "chore: release {version}"
70+
version_toml = ["pyproject.toml:tool.poetry.version"]
71+
72+
[tool.semantic_release.branches.develop]
73+
match = "develop"
8074

8175
[tool.bandit]
76+
assert_used = { skips = ["**/test_*.py"] }
8277

8378
[tool.black]
84-
target-version = ["py38", "py39"]
79+
target-version = ["py312"]
8580

8681
[tool.isort]
8782
profile = "black"
8883

89-
#########################################################################################
90-
# Publishing
91-
#########################################################################################
84+
[tool.pylint.BASIC]
85+
good-names = "log"
9286

93-
[tool.semantic_release]
94-
build_command = "poetry build"
95-
commit_message = "chore: release {version}"
96-
version_toml = ["pyproject.toml:tool.poetry.version"]
87+
[tool.pylint.MASTER]
88+
disable = [
89+
"C0114", # missing-module-docstring
90+
"C0115", # missing-class-docstring
91+
"C0116", # missing-function-docstring
92+
"R0801", # duplicate-code
93+
"W0511", # fixme
94+
]
9795

98-
[tool.semantic_release.branches.develop]
99-
match = "develop"
96+
[tool.pylint.pre-commit-hook]
97+
limit = 10
98+
99+
[tool.mypy]
100+
strict = true

src/huemon/commands/command_handler.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def create_name_to_command_mapping(
2626
return reduce(lambda p, c: {**p, c.name(): c(config, api)}, plugins, {})
2727

2828

29-
def __load_command_plugins(config: dict, command_plugins_path: str = None) -> dict:
29+
def __load_command_plugins(
30+
config: dict, command_plugins_path: str | None = None
31+
) -> dict:
3032
LOG.debug("Loading command plugins (path=%s)", command_plugins_path)
3133
if not command_plugins_path:
3234
return {}
@@ -44,7 +46,7 @@ def __load_command_plugins(config: dict, command_plugins_path: str = None) -> di
4446

4547

4648
def __load_plugins_and_hardwired_handlers(
47-
config: dict, command_plugins_path: str = None
49+
config: dict, command_plugins_path: str | None = None
4850
) -> dict:
4951
hardwired_commands_path = create_local_path(os.path.join("commands", "internal"))
5052

src/huemon/infrastructure/urllib_safe_opener.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class WhitelistedSchemaOpener(urllib.request.OpenerDirector):
13-
def __init__(self, handlers: typing.Iterable = None):
13+
def __init__(self, handlers: typing.Iterable | None = None):
1414
super().__init__()
1515
handlers = handlers or (
1616
urllib.request.UnknownHandler,

src/huemon/utils/plugins.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# LICENSE file in the root directory of this source tree.
55

66

7-
def __create_plugins_path(plugin_type: str, config: dict, fallback_path: str = None):
7+
def __create_plugins_path(
8+
plugin_type: str, config: dict, fallback_path: str | None = None
9+
):
810
plugins_section_exists = "plugins" in config
911
if not plugins_section_exists:
1012
return fallback_path
@@ -20,9 +22,9 @@ def __create_plugins_path(plugin_type: str, config: dict, fallback_path: str = N
2022
)
2123

2224

23-
def get_command_plugins_path(config: dict, fallback_path: str = None):
25+
def get_command_plugins_path(config: dict, fallback_path: str | None = None):
2426
return __create_plugins_path("commands", config, fallback_path)
2527

2628

27-
def get_discovery_plugins_path(config: dict, fallback_path: str = None):
29+
def get_discovery_plugins_path(config: dict, fallback_path: str | None = None):
2830
return __create_plugins_path("discoveries", config, fallback_path)

src/tests/fixtures.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def __generate_version():
2121
return str(time.process_time())
2222

2323

24-
def create_system_config(version: str = None, is_update_available: bool = False):
24+
def create_system_config(version: str | None = None, is_update_available: bool = False):
2525
return {
2626
FIELD_SYSTEM_SWUPDATE2: {
2727
FIELD_SYSTEM_SWUPDATE2_BRIDGE: {
28-
FIELD_STATE: FIELD_SYSTEM_SWUPDATE2_NOUPDATES
29-
if is_update_available
30-
else ""
28+
FIELD_STATE: (
29+
FIELD_SYSTEM_SWUPDATE2_NOUPDATES if is_update_available else ""
30+
)
3131
}
3232
},
3333
FIELD_SYSTEM_SWVERSION: version if version else __generate_version(),

src/tests/test_light_command.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_when_light_exists_return_status(mock_print: MagicMock):
9292
command_handler.exec("light", [SOME_LIGHT_MAC_0, "status"])
9393
command_handler.exec("light", [SOME_LIGHT_MAC_1, "status"])
9494

95-
mock_print.assert_has_calls(map(call, [1, 0]))
95+
mock_print.assert_has_calls(list(map(call, [1, 0])))
9696

9797
@staticmethod
9898
@patch("builtins.print")
@@ -122,7 +122,7 @@ def test_when_light_exists_return_is_upgrade_available(mock_print: MagicMock):
122122
command_handler.exec("light", [SOME_LIGHT_MAC_0, "is_upgrade_available"])
123123
command_handler.exec("light", [SOME_LIGHT_MAC_1, "is_upgrade_available"])
124124

125-
mock_print.assert_has_calls(map(call, [0, 1]))
125+
mock_print.assert_has_calls(list(map(call, [0, 1])))
126126

127127
@staticmethod
128128
@patch("builtins.print")
@@ -147,7 +147,7 @@ def test_when_light_exists_return_is_reachable(mock_print: MagicMock):
147147
command_handler.exec("light", [SOME_LIGHT_MAC_0, "reachable"])
148148
command_handler.exec("light", [SOME_LIGHT_MAC_1, "reachable"])
149149

150-
mock_print.assert_has_calls(map(call, [0, 1]))
150+
mock_print.assert_has_calls(list(map(call, [0, 1])))
151151

152152
@staticmethod
153153
@patch("builtins.print")
@@ -176,4 +176,4 @@ def test_when_light_exists_return_version(mock_print: MagicMock):
176176
command_handler.exec("light", [SOME_LIGHT_MAC_0, "version"])
177177
command_handler.exec("light", [SOME_LIGHT_MAC_1, "version"])
178178

179-
mock_print.assert_has_calls(map(call, [some_version_0, some_version_1]))
179+
mock_print.assert_has_calls(list(map(call, [some_version_0, some_version_1])))

src/tests/test_sensor_command.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_when_sensor_exists_return_battery_level(mock_print: MagicMock):
6060
command_handler.exec("sensor", [SOME_SENSOR_MAC_0, "battery:level"])
6161
command_handler.exec("sensor", [SOME_SENSOR_MAC_1, "battery:level"])
6262

63-
mock_print.assert_has_calls(map(call, [some_level_0, some_level_1]))
63+
mock_print.assert_has_calls(list(map(call, [some_level_0, some_level_1])))
6464

6565
@staticmethod
6666
@patch("builtins.print")
@@ -93,7 +93,7 @@ def test_when_sensor_exists_return_light_level(mock_print: MagicMock):
9393
command_handler.exec("sensor", [SOME_SENSOR_MAC_0, "light:level"])
9494
command_handler.exec("sensor", [SOME_SENSOR_MAC_1, "light:level"])
9595

96-
mock_print.assert_has_calls(map(call, [some_level_0, some_level_1]))
96+
mock_print.assert_has_calls(list(map(call, [some_level_0, some_level_1])))
9797

9898
@staticmethod
9999
@patch("builtins.print")
@@ -127,7 +127,7 @@ def test_when_sensor_exists_return_temperature(mock_print: MagicMock):
127127
command_handler.exec("sensor", [SOME_SENSOR_MAC_1, "temperature"])
128128

129129
mock_print.assert_has_calls(
130-
map(call, [some_temperature_0 * 0.01, some_temperature_1 * 0.01])
130+
list(map(call, [some_temperature_0 * 0.01, some_temperature_1 * 0.01]))
131131
)
132132

133133
@staticmethod
@@ -161,7 +161,7 @@ def test_when_sensor_exists_return_presence(mock_print: MagicMock):
161161
command_handler.exec("sensor", [SOME_SENSOR_MAC_0, "presence"])
162162
command_handler.exec("sensor", [SOME_SENSOR_MAC_1, "presence"])
163163

164-
mock_print.assert_has_calls(map(call, [some_presence_0, some_presence_1]))
164+
mock_print.assert_has_calls(list(map(call, [some_presence_0, some_presence_1])))
165165

166166
@staticmethod
167167
@patch("builtins.print")
@@ -195,5 +195,5 @@ def test_when_sensor_exists_return_reachable(mock_print: MagicMock):
195195
command_handler.exec("sensor", [SOME_SENSOR_MAC_1, "reachable"])
196196

197197
mock_print.assert_has_calls(
198-
map(call, [some_reachability_0, some_reachability_1])
198+
list(map(call, [some_reachability_0, some_reachability_1]))
199199
)

0 commit comments

Comments
 (0)