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 from typing import Any
import docker # type: ignore[import] import docker # type: ignore[import]
import docker.errors # type: ignore[import]
import numpy import numpy
from docker.models.containers import Container # type: ignore[import]
from prometheus_client import CollectorRegistry # type: ignore[import] from prometheus_client import CollectorRegistry # type: ignore[import]
from prometheus_client import Gauge, MetricsHandler, generate_latest from prometheus_client import Gauge, MetricsHandler, generate_latest
@ -108,7 +110,8 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc]
registry=registry, 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: try:
data = self.docker_api.inspect_container(container.id) data = self.docker_api.inspect_container(container.id)
except docker.errors.NotFound: except docker.errors.NotFound:
@ -121,7 +124,7 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc]
alert_threshold = int( alert_threshold = int(
data["Config"]["Labels"].get("io.prometheus.alert.downtime", 3600) 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( status_gauge.labels(
container.id, container.id,

View file

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