Add type annotations from monkeytype + jw-devops/test

Add type annotations as generated by monkeytype and jw-devops/test, plus some
hand editing to satisfy both monkeytype and mypy.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2020-04-10 17:55:36 +02:00
commit 77d43aebad
7 changed files with 51 additions and 42 deletions

View file

@ -1,9 +1,10 @@
import os, errno
import atexit
import tempfile
import filecmp
import inspect
from jwutils import log
from typing import Set
from jwutils import log
_tmpfiles: Set[str] = set()
@ -18,7 +19,7 @@ def silentremove(filename): #export
if e.errno != errno.ENOENT:
raise # re-raise exception if a different error occurred
def pad(token, total_size, right_align = False):
def pad(token: str, total_size: int, right_align: bool = False) -> str:
add = total_size - len(token)
if add <= 0:
return token
@ -63,7 +64,7 @@ def get_derived_classes(mod, base): # export
r.append(c)
return r
def commit_tmpfile(tmp, path): # export
def commit_tmpfile(tmp: str, path: str) -> None: # export
caller = log.get_caller_pos()
if os.path.isfile(path) and filecmp.cmp(tmp, path):
log.slog(log.INFO, "{} is up to date".format(path), caller=caller)