Fix incorrect type hinting

The type hinting indicated that the property was a dict, but it could also be None.
In cases where it was None, it would cause an exception, which was also fixed (since
unpacking None will break)
This commit is contained in:
Jaime van Kessel 2018-09-07 15:32:07 +02:00
parent c7350ff579
commit 20ec8828ed

View file

@ -385,7 +385,9 @@ class MachineManager(QObject):
# \param definition_id \type{str} definition id that needs to look for # \param definition_id \type{str} definition id that needs to look for
# \param metadata_filter \type{dict} list of metadata keys and values used for filtering # \param metadata_filter \type{dict} list of metadata keys and values used for filtering
@staticmethod @staticmethod
def getMachine(definition_id: str, metadata_filter: Dict[str, str] = None) -> Optional["GlobalStack"]: def getMachine(definition_id: str, metadata_filter: Optional[Dict[str, str]] = None) -> Optional["GlobalStack"]:
if metadata_filter is None:
metadata_filter = {}
machines = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter) machines = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter)
for machine in machines: for machine in machines:
if machine.definition.getId() == definition_id: if machine.definition.getId() == definition_id: