From 28ee448c44a4cad705c5ff4365b8896a4bdc1bdd Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 5 Dec 2022 12:42:55 -0800 Subject: [PATCH] remove unneeded type ignore comments --- jc/parsers/clf.py | 2 +- jc/parsers/clf_s.py | 2 +- jc/parsers/findmnt.py | 2 +- jc/parsers/git_ls_remote.py | 11 ++++++----- jc/parsers/lspci.py | 2 +- jc/parsers/os_prober.py | 4 ++-- jc/parsers/semver.py | 2 +- jc/parsers/sshd_conf.py | 16 ++++++++-------- jc/parsers/udevadm.py | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/jc/parsers/clf.py b/jc/parsers/clf.py index 64e942d0..214e13a3 100644 --- a/jc/parsers/clf.py +++ b/jc/parsers/clf.py @@ -211,7 +211,7 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]: # add unix timestamps if 'date' in log: - ts = jc.utils.timestamp(log['date'], format_hint=(1800,)) # type: ignore + ts = jc.utils.timestamp(log['date'], format_hint=(1800,)) log['epoch'] = ts.naive log['epoch_utc'] = ts.utc diff --git a/jc/parsers/clf_s.py b/jc/parsers/clf_s.py index 4e16c98b..610c7ca1 100644 --- a/jc/parsers/clf_s.py +++ b/jc/parsers/clf_s.py @@ -127,7 +127,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType: # add unix timestamps if 'date' in proc_data: - ts = jc.utils.timestamp(proc_data['date'], format_hint=(1800,)) # type: ignore + ts = jc.utils.timestamp(proc_data['date'], format_hint=(1800,)) proc_data['epoch'] = ts.naive proc_data['epoch_utc'] = ts.utc diff --git a/jc/parsers/findmnt.py b/jc/parsers/findmnt.py index 39002c74..3b32344a 100644 --- a/jc/parsers/findmnt.py +++ b/jc/parsers/findmnt.py @@ -122,7 +122,7 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]: kv_options = {} if 'options' in item: - opt_list = item['options'].split(',') # type: ignore + opt_list = item['options'].split(',') for option in opt_list: if '=' in option: diff --git a/jc/parsers/git_ls_remote.py b/jc/parsers/git_ls_remote.py index 80f6de51..352a9442 100644 --- a/jc/parsers/git_ls_remote.py +++ b/jc/parsers/git_ls_remote.py @@ -59,7 +59,7 @@ Examples: ... ] """ -from typing import List, Dict +from typing import List, Union from jc.jc_types import JSONDictType import jc.utils @@ -94,7 +94,7 @@ def _process(proc_data: List[JSONDictType]) -> JSONDictType: for item in proc_data: new_dict.update( { - item['reference']: item['commit'] # type: ignore + item['reference']: item['commit'] } ) @@ -105,7 +105,7 @@ def parse( data: str, raw: bool = False, quiet: bool = False -) -> List[JSONDictType]: +) -> Union[JSONDictType, List[JSONDictType]]: """ Main text parsing function @@ -122,7 +122,8 @@ def parse( jc.utils.compatibility(__name__, info.compatible, quiet) jc.utils.input_type_check(data) - raw_output: List[Dict] = [] + raw_output: List[JSONDictType] = [] + output_line: JSONDictType = {} if jc.utils.has_data(data): @@ -135,4 +136,4 @@ def parse( } raw_output.append(output_line) - return raw_output if raw else _process(raw_output) # type: ignore + return raw_output if raw else _process(raw_output) diff --git a/jc/parsers/lspci.py b/jc/parsers/lspci.py index 55e703db..7cd281b6 100644 --- a/jc/parsers/lspci.py +++ b/jc/parsers/lspci.py @@ -158,7 +158,7 @@ def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]: for key, val in item.items(): output[key] = val if key in int_list: - output[key + '_int'] = int(val, 16) # type: ignore + output[key + '_int'] = int(val, 16) new_list.append(output) return new_list diff --git a/jc/parsers/os_prober.py b/jc/parsers/os_prober.py index 06b71d29..701fcc8c 100644 --- a/jc/parsers/os_prober.py +++ b/jc/parsers/os_prober.py @@ -66,8 +66,8 @@ def _process(proc_data: JSONDictType) -> JSONDictType: Dictionary. Structured to conform to the schema. """ # check for EFI partition@boot-manager and split/add fields - if 'partition' in proc_data and '@' in proc_data['partition']: # type: ignore - new_part, efi_bootmgr = proc_data['partition'].split('@', maxsplit=1) # type: ignore + if 'partition' in proc_data and '@' in proc_data['partition']: + new_part, efi_bootmgr = proc_data['partition'].split('@', maxsplit=1) proc_data['partition'] = new_part proc_data['efi_bootmgr'] = efi_bootmgr diff --git a/jc/parsers/semver.py b/jc/parsers/semver.py index 7f6d7903..e80fe53e 100644 --- a/jc/parsers/semver.py +++ b/jc/parsers/semver.py @@ -78,7 +78,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType: for item in int_list: if item in proc_data: - proc_data[item] = int(proc_data[item]) # type: ignore + proc_data[item] = int(proc_data[item]) return proc_data diff --git a/jc/parsers/sshd_conf.py b/jc/parsers/sshd_conf.py index fc505a14..bcedccf2 100644 --- a/jc/parsers/sshd_conf.py +++ b/jc/parsers/sshd_conf.py @@ -526,7 +526,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType: # this is a list value if key == 'acceptenv': new_list: List[str] = [] - for item in val: # type: ignore + for item in val: new_list.extend(item.split()) proc_data[key] = new_list continue @@ -534,13 +534,13 @@ def _process(proc_data: JSONDictType) -> JSONDictType: # this is a list value if key == 'include': new_list = [] - for item in val: # type: ignore + for item in val: new_list.extend(item.split()) proc_data[key] = new_list continue if key == 'maxstartups': - maxstart_split = val.split(':', maxsplit=2) # type: ignore + maxstart_split = val.split(':', maxsplit=2) proc_data[key] = maxstart_split[0] if len(maxstart_split) > 1: proc_data[key + '_rate'] = maxstart_split[1] @@ -550,31 +550,31 @@ def _process(proc_data: JSONDictType) -> JSONDictType: if key == 'port': port_list: List[int] = [] - for item in val: # type: ignore + for item in val: port_list.append(int(item)) proc_data[key] = port_list continue if key == 'rekeylimit': - rekey_split = val.split(maxsplit=1) # type: ignore + rekey_split = val.split(maxsplit=1) proc_data[key] = rekey_split[0] if len(rekey_split) > 1: proc_data[key + '_time'] = rekey_split[1] continue if key == 'subsystem': - sub_split = val.split(maxsplit=1) # type: ignore + sub_split = val.split(maxsplit=1) proc_data[key] = sub_split[0] if len(sub_split) > 1: proc_data[key + '_command'] = sub_split[1] continue if key in split_fields_space: - proc_data[key] = val.split() # type: ignore + proc_data[key] = val.split() continue if key in split_fields_comma: - proc_data[key] = val.split(',') # type: ignore + proc_data[key] = val.split(',') continue for key, val in proc_data.items(): diff --git a/jc/parsers/udevadm.py b/jc/parsers/udevadm.py index d11d2be8..78002083 100644 --- a/jc/parsers/udevadm.py +++ b/jc/parsers/udevadm.py @@ -143,7 +143,7 @@ def _process(proc_data: JSONDictType) -> JSONDictType: List of Dictionaries. Structured to conform to the schema. """ if 'L' in proc_data: - proc_data['L'] = int(proc_data['L']) # type: ignore + proc_data['L'] = int(proc_data['L']) return proc_data