Add some type hints
This commit is contained in:
parent
0126452bf1
commit
534f258846
3 changed files with 13 additions and 6 deletions
|
|
@ -237,7 +237,10 @@ def get_smart_self_test_last_result(dev) -> str:
|
|||
result = 'Unknown'
|
||||
|
||||
# Parse SMART data
|
||||
data = dev.raw_smartctl.get('ata_smart_self_test_log', {}).get('standard', {}).get('table', [])
|
||||
data = dev.raw_smartctl.get(
|
||||
'ata_smart_self_test_log', {}).get(
|
||||
'standard', {}).get(
|
||||
'table', [])
|
||||
if not data:
|
||||
# No results found
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import platform
|
|||
import re
|
||||
import time
|
||||
|
||||
from typing import Union
|
||||
|
||||
|
||||
# STATIC VARIABLES
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
@ -73,7 +75,7 @@ def bytes_to_string(size, decimals=0, use_binary=True):
|
|||
return size_str
|
||||
|
||||
|
||||
def sleep(seconds=2):
|
||||
def sleep(seconds: Union[int, float] = 2) -> None:
|
||||
"""Simple wrapper for time.sleep."""
|
||||
time.sleep(seconds)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import traceback
|
|||
from collections import OrderedDict
|
||||
from prompt_toolkit import prompt
|
||||
from prompt_toolkit.validation import Validator, ValidationError
|
||||
from typing import Tuple
|
||||
|
||||
try:
|
||||
from functools import cache
|
||||
|
|
@ -234,10 +235,10 @@ class Menu():
|
|||
# Done
|
||||
return valid_answers
|
||||
|
||||
def _resolve_selection(self, selection):
|
||||
def _resolve_selection(self, selection) -> Tuple[str, dict]:
|
||||
"""Get menu item based on user selection, returns tuple."""
|
||||
offset = 1
|
||||
resolved_selection = None
|
||||
resolved_selection = tuple()
|
||||
if selection.isnumeric():
|
||||
# Enumerate over numbered entries
|
||||
entries = [
|
||||
|
|
@ -367,7 +368,7 @@ class Menu():
|
|||
details['Selected'] = details.get('Selected', False)
|
||||
self.toggles[name] = details
|
||||
|
||||
def advanced_select(self, prompt_msg='Please make a selection: '):
|
||||
def advanced_select(self, prompt_msg='Please make a selection: ') -> Tuple[str, dict]:
|
||||
"""Display menu and make multiple selections, returns tuple.
|
||||
|
||||
NOTE: Menu is displayed until an action entry is selected.
|
||||
|
|
@ -414,7 +415,8 @@ class Menu():
|
|||
# Done
|
||||
return selected_entry
|
||||
|
||||
def simple_select(self, prompt_msg='Please make a selection: ', update=True):
|
||||
def simple_select(
|
||||
self, prompt_msg='Please make a selection: ', update=True) -> Tuple[str, dict]:
|
||||
"""Display menu and make a single selection, returns tuple."""
|
||||
if update:
|
||||
self._update()
|
||||
|
|
|
|||
Loading…
Reference in a new issue