Type safety

This commit is contained in:
Scott Wallace 2023-01-12 09:15:33 +00:00
parent 762ef62098
commit 1999536b50
Signed by: scott
GPG key ID: AA742FDC5AFE2A72
2 changed files with 5 additions and 5 deletions

View file

@ -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,

View file

@ -1,3 +0,0 @@
[mypy]
plugins = numpy.typing.mypy_plugin
exclude = ['\.pyenv', 'venv']