Browse Source

Fix typing

Lipu Fei 6 years ago
parent
commit
cf5fd1c355

+ 4 - 2
cura/UI/MaterialOutputModel.py

@@ -1,11 +1,13 @@
 # Copyright (c) 2017 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
+from typing import Optional
+
 from PyQt5.QtCore import pyqtProperty, QObject
 
 
 class MaterialOutputModel(QObject):
-    def __init__(self, guid: str, type: str, color: str, brand: str, name: str, parent = None) -> None:
+    def __init__(self, guid: Optional[str], type: str, color: str, brand: str, name: str, parent = None) -> None:
         super().__init__(parent)
         self._guid = guid
         self._type = type
@@ -15,7 +17,7 @@ class MaterialOutputModel(QObject):
 
     @pyqtProperty(str, constant = True)
     def guid(self) -> str:
-        return self._guid
+        return self._guid if self._guid else ""
 
     @pyqtProperty(str, constant = True)
     def type(self) -> str:

+ 7 - 3
plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py

@@ -25,7 +25,11 @@ from UM.Version import Version
 from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice
 from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager
 
-from typing import Optional
+from typing import Optional, TYPE_CHECKING
+
+if TYPE_CHECKING:
+    from cura.Settings.GlobalStack import GlobalStack
+
 
 i18n_catalog = i18nCatalog("cura")
 
@@ -431,7 +435,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
         Logger.log("d", "Checking if cloud connection is possible...")
 
         # Pre-Check: Skip if active machine already has been cloud connected or you said don't ask again
-        active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"]
+        active_machine = self._application.getMachineManager().activeMachine  # type: Optional[GlobalStack]
         if active_machine:
             
             # Check 1A: Printer isn't already configured for cloud
@@ -519,7 +523,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
             return
 
     def _onDontAskMeAgain(self, checked: bool) -> None:
-        active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"]
+        active_machine = self._application.getMachineManager().activeMachine # type: Optional[GlobalStack]
         if active_machine:
             active_machine.setMetaDataEntry("do_not_show_cloud_message", checked)
             if checked: