Fix mypy type errors

CURA-6057
This commit is contained in:
Jaime van Kessel 2019-03-27 17:40:33 +01:00
parent 9091eaa6f8
commit 84aa7fd007
2 changed files with 12 additions and 10 deletions

View file

@ -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

View file

@ -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 = ""