Skip to content

Commit d80913d

Browse files
committed
added and fixed some type hinting stuff
1 parent ca14b46 commit d80913d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

csvexport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
from hantek1008 import Hantek1008, CorrectionDataType, ZeroOffsetShiftCompensationFunctionType
3-
from typing import Union, Optional, List, Dict, Tuple, Callable, Generator, Any
3+
from typing import Union, Optional, List, Dict, Any, IO
44
import logging as log
55
import argparse
66
import time
@@ -136,7 +136,7 @@ def main(csv_file_path: str,
136136
break
137137
except USBError as usb_error:
138138
# usb error bug occurred? try to close the device or reset it, sleep a sec and restart
139-
log.error(usb_error)
139+
log.error(str(usb_error))
140140
try:
141141
device.close()
142142
except:
@@ -204,7 +204,7 @@ def sample(device: Hantek1008, raw_or_volt: str, selected_channels: List[int], s
204204
# output_csv_filename = "channel_data.csv"
205205
if csv_file_path == '-':
206206
log.info("Exporting data to stdout...")
207-
csv_file = sys.stdout
207+
csv_file: IO[str] = sys.stdout
208208
elif csv_file_path.endswith(".xz"):
209209
log.info(f"Exporting data lzma-compressed to file '{csv_file_path}'...")
210210
csv_file = lzma.open(csv_file_path, 'at', newline='')

hantek1008.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,9 @@ def __calc_correction_factor(self, delta_to_zero: float, channel_id: int, vscale
771771
@overrides
772772
def request_samples_burst_mode(self, mode: str = "volt") \
773773
-> Union[
774-
Tuple[List[List[int]], List[List[int]]],
775-
Tuple[List[List[float]], List[List[float]]],
776-
Tuple[List[Union[List[float], List[int]]], List[Union[List[float], List[int]]]],
774+
Tuple[List[List[int]], List[List[int]]], # mode == raw
775+
Tuple[List[List[float]], List[List[float]]], # mode == volt
776+
Tuple[List[Union[List[float], List[int]]], List[Union[List[float], List[int]]]], # mode == volt+raw
777777
]:
778778
assert mode in ["raw", "volt", "volt+raw"]
779779
assert self.__zero_offset_shift_compensation_channel is None, \

utils/electro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def measure_offset_fft(samples_a: List[float],
151151

152152

153153
def calc_power(voltage_data: List[float],
154-
ampere_data: List[float]):
154+
ampere_data: List[float])\
155+
-> Tuple[float, float, float]:
155156
assert len(voltage_data) == len(ampere_data) > 0
156157
# P = 0 # active power/real power (Wirkleistung)
157158
# Q = 0 # reactive power (Blindleistung)

0 commit comments

Comments
 (0)