Skip to content
Snippets Groups Projects
Commit f50ee7ec authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Remove most pyright errors

Should be ok
parent 92731288
Branches
No related tags found
1 merge request!1First try of type hints
......@@ -43,17 +43,6 @@ DB_DEV_TYPE = "metadatadb.basic"
class Colors(enum.Enum):
DEFAULT = fore.WHITE
# ALIVE = fore.LIGHT_GRAY
# ATTRIBUTS = fore.LIGHT_YELLOW
# REQUEST = fore.LIGHT_RED
# IS_ALIVE = fore.LIGHT_MAGENTA
# REPLY = fore.LIGHT_CYAN
# NOTIFY = fore.LIGHT_GREEN
# DEV_TYPE = fore.LIGHT_BLUE
# ADDR = fore.LIGHT_RED
# INFO = fore.CYAN
# DB = fore.SPRING_GREEN_1
ALIVE = fore.LIGHT_GRAY
ATTRIBUTS = fore.YELLOW
REQUEST = fore.RED
......@@ -148,7 +137,7 @@ class DeviceInfo(object):
r.append([k, v])
# attributes
if len(self.attributes) > 0:
if self.attributes and len(self.attributes) > 0:
# tabulate has no minimal width so used this trick
r.append(['-'*22, '-'*46])
r.append(['Attributes', ''])
......@@ -172,9 +161,6 @@ class DeviceInfo(object):
class ToolboxHelper(object):
def __init__(self) -> None:
self.name = None # cmdline name
self.parser = None
self.engine = None # toolbox engine
self.device = None # current device
self.devices = [] # devices list (alive / walker)
# idle detector / force exit
self.exit_event = asyncio.Event()
......@@ -311,7 +297,7 @@ class ToolboxHelper(object):
print(color_value, end='')
msg.dump()
if color:
print(style.RESET, end='')
print(style.RESET, end='') # pyright: ignore
def color_for_msg(self, msg):
color_value = Colors.DEFAULT
......@@ -420,6 +406,7 @@ class ToolboxHelper(object):
def run_until_timeout(self, timeout=3):
""" run the engine until timeout """
if self.engine:
self.engine.add_timer(self.quit, timeout)
self.engine.run()
......@@ -448,7 +435,7 @@ class ToolboxHelper(object):
def colorize(color, text):
return f"{color}{text}{style.RESET}"
return f"{color}{text}{style.RESET}" # pyright: ignore
def now():
......@@ -671,7 +658,7 @@ def log():
color_value = Colors.REPLY
if color:
dump = f"{Colors.DEFAULT}{time.ctime()} {Colors.ADDR}{msg.source} {Colors.DEV_TYPE}{msg.dev_type}\t{color_value}{msg.action} {msg.body}{style.RESET}"
dump = f"{Colors.DEFAULT}{time.ctime()} {Colors.ADDR}{msg.source} {Colors.DEV_TYPE}{msg.dev_type}\t{color_value}{msg.action} {msg.body}{style.RESET}" # pyright: ignore
else:
dump = f"{time.ctime()} {msg.source} {msg.dev_type}\t{msg.action} {msg.body}"
print(dump)
......@@ -1012,4 +999,3 @@ def shell():
print("* Ending Engine")
eng.shutdown()
print("* Bye bye")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment