allow passing a single Tool to be used as the default

This commit is contained in:
Jan Petykiewicz 2022-03-01 18:41:36 -08:00 committed by jan
parent df320e80cc
commit 9891ba9e47

View File

@ -181,7 +181,7 @@ class Device(Copyable, Mirrorable):
pattern: Optional[Pattern] = None, pattern: Optional[Pattern] = None,
ports: Optional[Dict[str, Port]] = None, ports: Optional[Dict[str, Port]] = None,
*, *,
tools: Optional[Dict[Optional[str], Tool]] = None, tools: Union[None, Tool, Dict[Optional[str], Tool]] = None,
name: Optional[str] = None, name: Optional[str] = None,
) -> None: ) -> None:
""" """
@ -209,6 +209,8 @@ class Device(Copyable, Mirrorable):
if tools is None: if tools is None:
self.tools = {} self.tools = {}
elif isinstance(tools, Tool):
self.tools = {None: tools}
else: else:
self.tools = tools self.tools = tools