From 1789a8f33e3f939612f061a340a50b0625883fd3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 15 Jun 2018 13:20:20 +0200 Subject: [PATCH] Fix type of SelectionPass Contributes to issue CURA-5330. --- cura/CuraApplication.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 9db53c0836..3dc0ef02d7 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -2,7 +2,6 @@ # Cura is released under the terms of the LGPLv3 or higher. import copy -import json import os import sys import time @@ -14,7 +13,8 @@ from PyQt5.QtGui import QColor, QIcon from PyQt5.QtWidgets import QMessageBox from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType -from UM.Qt.QtApplication import QtApplication +from typing import cast, TYPE_CHECKING + from UM.Scene.SceneNode import SceneNode from UM.Scene.Camera import Camera from UM.Math.Vector import Vector @@ -28,6 +28,8 @@ from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Mesh.ReadMeshJob import ReadMeshJob from UM.Logger import Logger from UM.Preferences import Preferences +from UM.Qt.QtApplication import QtApplication #The class we're inheriting from. +from UM.View.SelectionPass import SelectionPass #For typing. from UM.Scene.Selection import Selection from UM.Scene.GroupDecorator import GroupDecorator from UM.Settings.ContainerStack import ContainerStack @@ -109,8 +111,7 @@ from UM.FlameProfiler import pyqtSlot numpy.seterr(all = "ignore") -MYPY = False -if not MYPY: +if TYPE_CHECKING: try: from cura.CuraVersion import CuraVersion, CuraBuildType, CuraDebugMode except ImportError: @@ -1719,7 +1720,7 @@ class CuraApplication(QtApplication): def _onContextMenuRequested(self, x: float, y: float) -> None: # Ensure we select the object if we request a context menu over an object without having a selection. if not Selection.hasSelection(): - node = self.getController().getScene().findObject(self.getRenderer().getRenderPass("selection").getIdAtPosition(x, y)) + node = cast(SelectionPass, self.getController().getScene().findObject(self.getRenderer().getRenderPass("selection"))).getIdAtPosition(x, y) if node: while(node.getParent() and node.getParent().callDecoration("isGroup")): node = node.getParent()