From e156b0db453e99fb0f74b618fd343218f978ff68 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 26 Jan 2022 17:08:03 -0800 Subject: [PATCH] add type hints --- docs/parsers/universal.md | 4 ++-- jc/parsers/universal.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/parsers/universal.md b/docs/parsers/universal.md index a1c62688..f360f875 100644 --- a/docs/parsers/universal.md +++ b/docs/parsers/universal.md @@ -15,7 +15,7 @@ jc - JSON CLI output utility universal Parsers ### simple\_table\_parse ```python -def simple_table_parse(data) +def simple_table_parse(data: List[str]) -> List[Dict] ``` Parse simple tables. The last column may contain data with spaces. @@ -40,7 +40,7 @@ Returns: ### sparse\_table\_parse ```python -def sparse_table_parse(data, delim='\u2063') +def sparse_table_parse(data: List[str], delim: Optional[str] = '\u2063') -> List[Dict] ``` Parse tables with missing column data or with spaces in column data. diff --git a/jc/parsers/universal.py b/jc/parsers/universal.py index 9d1bfa64..22bf2705 100644 --- a/jc/parsers/universal.py +++ b/jc/parsers/universal.py @@ -2,9 +2,10 @@ import string +from typing import List, Dict, Optional -def simple_table_parse(data): +def simple_table_parse(data: List[str]) -> List[Dict]: """ Parse simple tables. The last column may contain data with spaces. @@ -32,7 +33,7 @@ def simple_table_parse(data): return raw_output -def sparse_table_parse(data, delim='\u2063'): +def sparse_table_parse(data: List[str], delim: Optional[str] ='\u2063') -> List[Dict]: """ Parse tables with missing column data or with spaces in column data.