From 1999536b5067031d4665d0a9c33d7d52adf290cd Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Thu, 12 Jan 2023 09:15:33 +0000 Subject: [PATCH] Type safety --- dockstat.py | 7 +++++-- mypy.ini | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 mypy.ini diff --git a/dockstat.py b/dockstat.py index 30ae617..562bd38 100644 --- a/dockstat.py +++ b/dockstat.py @@ -12,7 +12,9 @@ from http.server import HTTPServer from typing import Any import docker # type: ignore[import] +import docker.errors # type: ignore[import] import numpy +from docker.models.containers import Container # type: ignore[import] from prometheus_client import CollectorRegistry # type: ignore[import] from prometheus_client import Gauge, MetricsHandler, generate_latest @@ -108,7 +110,8 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc] registry=registry, ) - for container in self.docker_client.containers.list(all=True): + container: Container + for container in self.docker_client.containers.list(all=True): # type: ignore try: data = self.docker_api.inspect_container(container.id) except docker.errors.NotFound: @@ -121,7 +124,7 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc] alert_threshold = int( data["Config"]["Labels"].get("io.prometheus.alert.downtime", 3600) ) - starttime: numpy.longlong = numpy.datetime64(started_at, "s").astype("long") + starttime = numpy.datetime64(started_at, "s").astype("long") status_gauge.labels( container.id, diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 46d21cc..0000000 --- a/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -plugins = numpy.typing.mypy_plugin -exclude = ['\.pyenv', 'venv']