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,7 +1,7 @@
from jwutils.stree.StringTree import *
from jwutils.log import *
def _cleanup_line(line):
def _cleanup_line(line: str) -> str:
line = line.strip()
r = ''
in_quote = None
@ -20,7 +20,7 @@ def _cleanup_line(line):
return r[1:-1]
return r
def parse(s, allow_full_lines=True, root_content='root'): # export
def parse(s: str, allow_full_lines: bool=True, root_content: str='root') -> StringTree: # export
slog(DEBUG, "parsing", s)
root = StringTree('', content=root_content)
sec = ''
@ -66,7 +66,7 @@ def parse(s, allow_full_lines=True, root_content='root'): # export
root.add(sec + '.' + cleanup_string(lhs), cleanup_string(rhs), split=split)
return root
def read(path, root_content='root'): # export
def read(path: str, root_content: str='root') -> StringTree: # export
with open(path, 'r') as infile:
s = infile.read()
return parse(s, root_content=root_content)