Fix typing issues

This commit is contained in:
Jaime van Kessel 2019-08-29 16:23:10 +02:00
parent 2676c7fa2f
commit d548404dfd
4 changed files with 10 additions and 4 deletions

View file

@ -921,12 +921,12 @@ class CuraApplication(QtApplication):
# Can't deprecate this function since the deprecation marker collides with pyqtSlot! # Can't deprecate this function since the deprecation marker collides with pyqtSlot!
@pyqtSlot(result = QObject) @pyqtSlot(result = QObject)
def getMaterialManager(self, *args) -> "MaterialManager": def getMaterialManager(self, *args) -> cura.Machines.MaterialManager.MaterialManager:
return cura.Machines.MaterialManager.MaterialManager.getInstance() return cura.Machines.MaterialManager.MaterialManager.getInstance()
# Can't deprecate this function since the deprecation marker collides with pyqtSlot! # Can't deprecate this function since the deprecation marker collides with pyqtSlot!
@pyqtSlot(result = QObject) @pyqtSlot(result = QObject)
def getQualityManager(self, *args) -> "QualityManager": def getQualityManager(self, *args) -> cura.Machines.QualityManager.QualityManager:
return cura.Machines.QualityManager.QualityManager.getInstance() return cura.Machines.QualityManager.QualityManager.getInstance()
def getIntentManager(self, *args) -> IntentManager: def getIntentManager(self, *args) -> IntentManager:

View file

@ -152,7 +152,10 @@ class MaterialManagementModel(QObject):
extruder_stack = application.getMachineManager().activeStack extruder_stack = application.getMachineManager().activeStack
active_variant_name = extruder_stack.variant.getName() active_variant_name = extruder_stack.variant.getName()
approximate_diameter = int(extruder_stack.approximateMaterialDiameter) approximate_diameter = int(extruder_stack.approximateMaterialDiameter)
machine_node = ContainerTree.getInstance().machines[application.getGlobalContainerStack().definition.getId()] global_container_stack = application.getGlobalContainerStack()
if not global_container_stack:
return ""
machine_node = ContainerTree.getInstance().machines[global_container_stack.definition.getId()]
preferred_material_node = machine_node.variants[active_variant_name].preferredMaterial(approximate_diameter) preferred_material_node = machine_node.variants[active_variant_name].preferredMaterial(approximate_diameter)
# Create a new ID & new metadata for the new material. # Create a new ID & new metadata for the new material.

View file

@ -14,6 +14,7 @@ if TYPE_CHECKING:
from typing import Dict from typing import Dict
from cura.Machines.MachineNode import MachineNode from cura.Machines.MachineNode import MachineNode
## This class represents an extruder variant in the container tree. ## This class represents an extruder variant in the container tree.
# #
# The subnodes of these nodes are materials. # The subnodes of these nodes are materials.
@ -54,7 +55,7 @@ class VariantNode(ContainerNode):
materials_per_base_file = {material["base_file"]: material for material in all_materials} materials_per_base_file = {material["base_file"]: material for material in all_materials}
materials_per_base_file.update({material["base_file"]: material for material in printer_specific_materials}) # Printer-specific profiles override global ones. materials_per_base_file.update({material["base_file"]: material for material in printer_specific_materials}) # Printer-specific profiles override global ones.
materials_per_base_file.update({material["base_file"]: material for material in variant_specific_materials}) # Variant-specific profiles override all of those. materials_per_base_file.update({material["base_file"]: material for material in variant_specific_materials}) # Variant-specific profiles override all of those.
materials = materials_per_base_file.values() materials = list(materials_per_base_file.values())
# Filter materials based on the exclude_materials property. # Filter materials based on the exclude_materials property.
filtered_materials = [material for material in materials if material["id"] not in self.machine.exclude_materials] filtered_materials = [material for material in materials if material["id"] not in self.machine.exclude_materials]

View file

@ -1515,6 +1515,8 @@ class MachineManager(QObject):
# \param intent_category The intent category to change to. # \param intent_category The intent category to change to.
def setIntentByCategory(self, intent_category: str) -> None: def setIntentByCategory(self, intent_category: str) -> None:
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if global_stack is None:
return
container_tree = ContainerTree.getInstance() container_tree = ContainerTree.getInstance()
for extruder in global_stack.extruderList: for extruder in global_stack.extruderList:
definition_id = global_stack.definition.getId() definition_id = global_stack.definition.getId()