Skip to content

Commit

Permalink
fix mypy setup
Browse files Browse the repository at this point in the history
  • Loading branch information
miaucl committed Sep 19, 2024
1 parent 8fc30ec commit beebb20
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
3 changes: 1 addition & 2 deletions mypi.ini → mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
python_version = 3.12
plugins = pydantic.mypy
show_error_codes = true
follow_imports = silent
local_partial_types = true
strict_equality = true
no_implicit_optional = true
warn_incomplete_stub = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
warn_unused_ignores = false
enable_error_code = ignore-without-code, redundant-self, truthy-iterable
disable_error_code = annotation-unchecked, import-not-found, import-untyped
extra_checks = false
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[build-system]
requires = [
"setuptools>=42",
"setuptools>=46.4.0",
"wheel"
]
build-backend = "setuptools.build_meta"

[tool.ruff]

target-version = "py312"


[tool.ruff.lint]
select = [
"B002", # Python does not support the unary prefix increment
Expand Down
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
paho-mqtt
types-paho-mqtt
mypy>=1.8.0
mypy
pydantic
pre-commit>=3.6.1
python-dotenv>=1.0.1
ruff~=0.6
Expand Down
4 changes: 2 additions & 2 deletions systemctl2mqtt/helpers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""systemctl2mqtt helpers."""

from typing import Dict, Union
from typing import Union

from .type_definitions import ServiceEntry


def clean_for_discovery(
val: ServiceEntry,
) -> Dict[str, Union[str, int, float, object]]:
) -> dict[str, Union[str, int, float, object]]:
"""Cleanup a typed dict for home assistant discovery, which is quite picky and does not like empty of None values.
Parameters
Expand Down
12 changes: 6 additions & 6 deletions systemctl2mqtt/systemctl2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
from threading import Thread
from time import sleep, time
from typing import Any, Dict
from typing import Any

import paho.mqtt.client

Expand Down Expand Up @@ -128,10 +128,10 @@ class Systemctl2Mqtt:

systemctl_events: Queue[dict[str, str]] = Queue(maxsize=MAX_QUEUE_SIZE)
systemctl_stats: Queue[list[str]] = Queue(maxsize=MAX_QUEUE_SIZE)
known_event_services: Dict[str, ServiceEvent] = {}
known_stat_services: Dict[str, Dict[int, ServiceStatsRef]] = {}
last_stat_services: Dict[str, ServiceStats | Dict[str, Any]] = {}
pending_destroy_operations: Dict[str, float] = {}
known_event_services: dict[str, ServiceEvent] = {}
known_stat_services: dict[str, dict[int, ServiceStatsRef]] = {}
last_stat_services: dict[str, ServiceStats | dict[str, Any]] = {}
pending_destroy_operations: dict[str, float] = {}

mqtt: paho.mqtt.client.Client

Expand Down Expand Up @@ -206,7 +206,7 @@ def __init__(self, cfg: Systemctl2MqttConfig, do_not_exit: bool = False):
try:
# Setup MQTT
self.mqtt = paho.mqtt.client.Client(
callback_api_version=paho.mqtt.client.CallbackAPIVersion.VERSION2, # type: ignore
callback_api_version=paho.mqtt.client.CallbackAPIVersion.VERSION2, # type: ignore[attr-defined, call-arg]
client_id=self.cfg["mqtt_client_id"],
)
self.mqtt.username_pw_set(
Expand Down

0 comments on commit beebb20

Please sign in to comment.