fix: clear all mypy errors

Annotate untyped containers and Optional attributes, type the stdlib-shaped
metric dicts in the client plugins, and add types-PyYAML/types-psutil to the
dev extras plus a mypy override for nio/mattermostdriver (no stubs).

Behaviour fixes found on the way: enable_kernel_timestamps() now returns False
when SO_TIMESTAMP is unknown instead of raising TypeError, send_shutdown is
defined at module level so cleanup() cannot hit a NameError, and a failed
subprocess returncode falls back to UNKNOWN.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 05:04:54 -04:00
co-authored by Claude Sonnet 5.5
parent 748349a7b9
commit 445ff6b474
20 changed files with 63 additions and 49 deletions
+4 -4
View File
@@ -10,7 +10,7 @@ from typing import Dict, Any, Optional
try:
import psutil
except ImportError:
psutil = None
psutil = None # type: ignore[assignment]
from hbd.client.plugin import MonitorPlugin
from hbd.client.connectivity import get_shared
@@ -63,7 +63,7 @@ class NetworkMonitorPlugin(MonitorPlugin):
raise ImportError("psutil library is required for network_monitor plugin")
# Store previous I/O counters for delta calculation
self._prev_io = {}
self._prev_io: Dict[str, Any] = {}
async def initialize(self):
"""Initialize the plugin (check psutil availability)."""
@@ -124,7 +124,7 @@ class NetworkMonitorPlugin(MonitorPlugin):
async def _collect_metrics(self) -> Dict[str, Any]:
"""Collect network metrics from psutil."""
metrics = {}
metrics: Dict[str, Any] = {}
# Collect per-interface I/O counters
try:
@@ -169,7 +169,7 @@ class NetworkMonitorPlugin(MonitorPlugin):
if self.include_connections:
try:
connections = psutil.net_connections(kind='inet')
conn_stats = {}
conn_stats: Dict[str, int] = {}
# Count connections by state
for conn in connections: