mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
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:
parent
952bf4a4e1
commit
77d43aebad
7 changed files with 51 additions and 42 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue