1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

remove unneeded type ignore comments

This commit is contained in:
Kelly Brazil
2022-12-05 12:42:55 -08:00
parent 688a2099b5
commit 28ee448c44
9 changed files with 22 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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():

View File

@ -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