From f9e2618b3d19c9a84efc77ef0af0b1955dd5b7f0 Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Wed, 28 Aug 2024 17:12:48 -0500 Subject: [PATCH] Improve type checking of the daemon code - add `boto3-stubs[logs]` for type checking of daemon code - remove (now unnecessary) mypy config - use `__future__` annotations style for some module-level annotations --- daemon/globus_cw_daemon/daemon.py | 9 ++++----- daemon/mypy.ini | 2 -- tox.ini | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 daemon/mypy.ini diff --git a/daemon/globus_cw_daemon/daemon.py b/daemon/globus_cw_daemon/daemon.py index ccf0c5f..f128638 100644 --- a/daemon/globus_cw_daemon/daemon.py +++ b/daemon/globus_cw_daemon/daemon.py @@ -2,6 +2,8 @@ """ Upload messages to cloud watch logs """ +from __future__ import annotations + import errno import json import logging @@ -10,7 +12,6 @@ import sys import threading import time -import typing as t import globus_cw_daemon.config as config import globus_cw_daemon.cwlogs as cwlogs @@ -32,14 +33,12 @@ # Data shared with flush thread _g_lock = threading.Lock() -_g_queue: t.List[cwlogs.Event] = [] # List of Events +_g_queue: list[cwlogs.Event] = [] # List of Events _g_nr_dropped = 0 # get constant instance_id on start try: - INSTANCE_ID: t.Union[str, None] = os.readlink("/var/lib/cloud/instance").split("/")[ - -1 - ] + INSTANCE_ID: str | None = os.readlink("/var/lib/cloud/instance").split("/")[-1] except OSError: INSTANCE_ID = None diff --git a/daemon/mypy.ini b/daemon/mypy.ini deleted file mode 100644 index 3d1cd43..0000000 --- a/daemon/mypy.ini +++ /dev/null @@ -1,2 +0,0 @@ -[mypy] -ignore_missing_imports = true diff --git a/tox.ini b/tox.ini index 7963ba8..f169575 100644 --- a/tox.ini +++ b/tox.ini @@ -41,6 +41,7 @@ deps = mypy client: ./client daemon: ./daemon + daemon: boto3-stubs[logs] commands = client: mypy globus_cw_client {posargs} daemon: mypy globus_cw_daemon {posargs}