diff --git a/cura/UI/ObjectsModel.py b/cura/UI/ObjectsModel.py index 09304451a5..36d590a668 100644 --- a/cura/UI/ObjectsModel.py +++ b/cura/UI/ObjectsModel.py @@ -51,12 +51,14 @@ class ObjectsModel(ListModel): group_nr = 1 name_count_dict = defaultdict(int) # type: Dict[str, int] - for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()): + for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()): # type: ignore if not isinstance(node, SceneNode): continue if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"): continue - if node.getParent() and node.getParent().callDecoration("isGroup"): + + parent = node.getParent() + if parent and parent.callDecoration("isGroup"): continue # Grouped nodes don't need resetting as their parent (the group) is resetted) if not node.callDecoration("isSliceable") and not node.callDecoration("isGroup"): continue @@ -72,7 +74,7 @@ class ObjectsModel(ListModel): group_nr += 1 if hasattr(node, "isOutsideBuildArea"): - is_outside_build_area = node.isOutsideBuildArea() + is_outside_build_area = node.isOutsideBuildArea() # type: ignore else: is_outside_build_area = False diff --git a/cura/UI/TextManager.py b/cura/UI/TextManager.py index a2708801bb..c09fc9b1c2 100644 --- a/cura/UI/TextManager.py +++ b/cura/UI/TextManager.py @@ -2,7 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. import collections -from typing import Optional +from typing import Optional, Dict, List, cast from PyQt5.QtCore import QObject, pyqtSlot @@ -29,9 +29,9 @@ class TextManager(QObject): def _loadChangeLogText(self) -> str: # Load change log texts and organize them with a dict file_path = Resources.getPath(Resources.Texts, "change_log.txt") - change_logs_dict = {} + change_logs_dict = {} # type: Dict[Version, Dict[str, List[str]]] with open(file_path, "r", encoding = "utf-8") as f: - open_version = None + open_version = None # type: Optional[Version] open_header = "" # Initialise to an empty header in case there is no "*" in the first line of the changelog for line in f: line = line.replace("\n", "") @@ -43,11 +43,11 @@ class TextManager(QObject): change_logs_dict[open_version] = collections.OrderedDict() elif line.startswith("*"): open_header = line.replace("*", "") - change_logs_dict[open_version][open_header] = [] + change_logs_dict[cast(Version, open_version)][open_header] = [] elif line != "": - if open_header not in change_logs_dict[open_version]: - change_logs_dict[open_version][open_header] = [] - change_logs_dict[open_version][open_header].append(line) + if open_header not in change_logs_dict[cast(Version, open_version)]: + change_logs_dict[cast(Version, open_version)][open_header] = [] + change_logs_dict[cast(Version, open_version)][open_header].append(line) # Format changelog text content = ""