Refactor: Add annotations to base lftools 33/72233/1
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Fri, 6 Oct 2023 21:52:27 +0000 (14:52 -0700)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Fri, 6 Oct 2023 21:52:27 +0000 (14:52 -0700)
Issue: RELENG-4933
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
Change-Id: I9d793ebe4db3ca47dafee56c9016789f8bcd3f1f

lftools/__init__.py
mypy.ini [new file with mode: 0644]

index fa8c8d3..e954bdc 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: EPL-1.0
 ##############################################################################
-# Copyright (c) 2017 The Linux Foundation and others.
+# Copyright (c) 2017, 2023 The Linux Foundation and others.
 #
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
@@ -9,8 +9,10 @@
 #
 # Contributors:
 #   Thanh Ha - Initial implementation
+#   Linux Foundation Release Engineering
 ##############################################################################
 """lftools package."""
+from __future__ import annotations
 
 __author__ = "Thanh Ha"
 __summary__ = "Linux Foundation Release Engineering Tools"
@@ -22,11 +24,11 @@ import sys
 class LogFormatter(logging.Formatter):
     """Custom log formatter."""
 
-    default_fmt = logging.Formatter("%(levelname)s: %(message)s")
-    debug_fmt = logging.Formatter("%(levelname)s: %(name)s:%(lineno)d: %(message)s")
-    info_fmt = logging.Formatter("%(message)s")
+    default_fmt: logging.Formatter = logging.Formatter("%(levelname)s: %(message)s")
+    debug_fmt: logging.Formatter = logging.Formatter("%(levelname)s: %(name)s:%(lineno)d: %(message)s")
+    info_fmt: logging.Formatter = logging.Formatter("%(message)s")
 
-    def format(self, record):
+    def format(self, record: logging.LogRecord) -> str:
         """Format log messages depending on log level."""
         if record.levelno == logging.INFO:
             return self.info_fmt.format(record)
diff --git a/mypy.ini b/mypy.ini
new file mode 100644 (file)
index 0000000..8c8efb4
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,24 @@
+[mypy]
+warn_return_any = True
+warn_unused_configs = True
+
+[mypy-defusedxml.minidom.*]
+ignore_missing_imports = True
+
+[mypy-docker.*]
+ignore_missing_imports = True
+
+[mypy-jenkins.*]
+ignore_missing_imports = True
+
+[mypy-ldap.*]
+ignore_missing_imports = True
+
+[mypy-oauth2client.*]
+ignore_missing_imports = True
+
+[mypy-pygerrit2.*]
+ignore_missing_imports = True
+
+[mypy-ruamel.*]
+ignore_missing_imports = True