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'
|
result = 'Unknown'
|
||||||
|
|
||||||
# Parse SMART data
|
# 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:
|
if not data:
|
||||||
# No results found
|
# No results found
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import platform
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
# STATIC VARIABLES
|
# STATIC VARIABLES
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -73,7 +75,7 @@ def bytes_to_string(size, decimals=0, use_binary=True):
|
||||||
return size_str
|
return size_str
|
||||||
|
|
||||||
|
|
||||||
def sleep(seconds=2):
|
def sleep(seconds: Union[int, float] = 2) -> None:
|
||||||
"""Simple wrapper for time.sleep."""
|
"""Simple wrapper for time.sleep."""
|
||||||
time.sleep(seconds)
|
time.sleep(seconds)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import traceback
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from prompt_toolkit import prompt
|
from prompt_toolkit import prompt
|
||||||
from prompt_toolkit.validation import Validator, ValidationError
|
from prompt_toolkit.validation import Validator, ValidationError
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from functools import cache
|
from functools import cache
|
||||||
|
|
@ -234,10 +235,10 @@ class Menu():
|
||||||
# Done
|
# Done
|
||||||
return valid_answers
|
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."""
|
"""Get menu item based on user selection, returns tuple."""
|
||||||
offset = 1
|
offset = 1
|
||||||
resolved_selection = None
|
resolved_selection = tuple()
|
||||||
if selection.isnumeric():
|
if selection.isnumeric():
|
||||||
# Enumerate over numbered entries
|
# Enumerate over numbered entries
|
||||||
entries = [
|
entries = [
|
||||||
|
|
@ -367,7 +368,7 @@ class Menu():
|
||||||
details['Selected'] = details.get('Selected', False)
|
details['Selected'] = details.get('Selected', False)
|
||||||
self.toggles[name] = details
|
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.
|
"""Display menu and make multiple selections, returns tuple.
|
||||||
|
|
||||||
NOTE: Menu is displayed until an action entry is selected.
|
NOTE: Menu is displayed until an action entry is selected.
|
||||||
|
|
@ -414,7 +415,8 @@ class Menu():
|
||||||
# Done
|
# Done
|
||||||
return selected_entry
|
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."""
|
"""Display menu and make a single selection, returns tuple."""
|
||||||
if update:
|
if update:
|
||||||
self._update()
|
self._update()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue