Browse Source

Fix bunch of issues found by pylint

Jaime van Kessel 5 years ago
parent
commit
e74f049142

+ 2 - 2
cura/Arranging/Arrange.py

@@ -69,7 +69,7 @@ class Arrange:
             points = copy.deepcopy(vertices._points)
 
             # After scaling (like up to 0.1 mm) the node might not have points
-            if len(points) == 0:
+            if not points:
                 continue
 
             shape_arr = ShapeArray.fromPolygon(points, scale = scale)
@@ -114,7 +114,7 @@ class Arrange:
             found_spot = True
             self.place(x, y, offset_shape_arr)  # place the object in arranger
         else:
-            Logger.log("d", "Could not find spot!"),
+            Logger.log("d", "Could not find spot!")
             found_spot = False
             node.setPosition(Vector(200, center_y, 100))
         return found_spot

+ 2 - 2
cura/Arranging/ArrangeObjectsAllBuildPlatesJob.py

@@ -29,7 +29,7 @@ class ArrangeArray:
         self._has_empty = False
         self._arrange = []  # type: List[Arrange]
 
-    def _update_first_empty(self):
+    def _updateFirstEmpty(self):
         for i, a in enumerate(self._arrange):
             if a.isEmpty:
                 self._first_empty = i
@@ -42,7 +42,7 @@ class ArrangeArray:
         new_arrange = Arrange.create(x = self._x, y = self._y, fixed_nodes = self._fixed_nodes)
         self._arrange.append(new_arrange)
         self._count += 1
-        self._update_first_empty()
+        self._updateFirstEmpty()
 
     def count(self):
         return self._count

+ 17 - 11
cura/BuildVolume.py

@@ -1,15 +1,21 @@
 # Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
+
+import numpy
+import math
+
+from typing import List, Optional, TYPE_CHECKING, Any, Set, cast, Iterable, Dict
+
 from UM.Mesh.MeshData import MeshData
-from cura.Scene.CuraSceneNode import CuraSceneNode
-from cura.Settings.ExtruderManager import ExtruderManager
+from UM.Mesh.MeshBuilder import MeshBuilder
+
 from UM.Application import Application #To modify the maximum zoom level.
 from UM.i18n import i18nCatalog
 from UM.Scene.Platform import Platform
 from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
 from UM.Scene.SceneNode import SceneNode
 from UM.Resources import Resources
-from UM.Mesh.MeshBuilder import MeshBuilder
+
 from UM.Math.Vector import Vector
 from UM.Math.Matrix import Matrix
 from UM.Math.Color import Color
@@ -17,23 +23,23 @@ from UM.Math.AxisAlignedBox import AxisAlignedBox
 from UM.Math.Polygon import Polygon
 from UM.Message import Message
 from UM.Signal import Signal
-from PyQt5.QtCore import QTimer
 from UM.View.RenderBatch import RenderBatch
 from UM.View.GL.OpenGL import OpenGL
-from cura.Settings.GlobalStack import GlobalStack
 
-catalog = i18nCatalog("cura")
+from cura.Settings.GlobalStack import GlobalStack
+from cura.Scene.CuraSceneNode import CuraSceneNode
+from cura.Settings.ExtruderManager import ExtruderManager
 
-import numpy
-import math
+from PyQt5.QtCore import QTimer
 
-from typing import List, Optional, TYPE_CHECKING, Any, Set, cast, Iterable, Dict
 
 if TYPE_CHECKING:
     from cura.CuraApplication import CuraApplication
     from cura.Settings.ExtruderStack import ExtruderStack
     from UM.Settings.ContainerStack import ContainerStack
 
+catalog = i18nCatalog("cura")
+
 # Radius of disallowed area in mm around prime. I.e. how much distance to keep from prime position.
 PRIME_CLEARANCE = 6.5
 
@@ -1012,13 +1018,13 @@ class BuildVolume(SceneNode):
         all_values = ExtruderManager.getInstance().getAllExtruderSettings(setting_key, "value")
         all_types = ExtruderManager.getInstance().getAllExtruderSettings(setting_key, "type")
         for i, (setting_value, setting_type) in enumerate(zip(all_values, all_types)):
-            if not setting_value and (setting_type == "int" or setting_type == "float"):
+            if not setting_value and setting_type in ["int", "float"]:
                 all_values[i] = 0
         return all_values
 
     def _calculateBedAdhesionSize(self, used_extruders):
         if self._global_container_stack is None:
-            return
+            return None
 
         container_stack = self._global_container_stack
         adhesion_type = container_stack.getProperty("adhesion_type", "value")

+ 2 - 0
cura/CrashHandler.py

@@ -58,6 +58,8 @@ class CrashHandler:
         self.traceback = tb
         self.has_started = has_started
         self.dialog = None # Don't create a QDialog before there is a QApplication
+        self.cura_version = None
+        self.cura_locale = None
 
         Logger.log("c", "An uncaught error has occurred!")
         for line in traceback.format_exception(exception_type, value, tb):

+ 1 - 3
cura/CuraActions.py

@@ -3,17 +3,15 @@
 
 from PyQt5.QtCore import QObject, QUrl
 from PyQt5.QtGui import QDesktopServices
-from typing import List, Optional, cast
+from typing import List, cast
 
 from UM.Event import CallFunctionEvent
 from UM.FlameProfiler import pyqtSlot
-from UM.Math.Quaternion import Quaternion
 from UM.Math.Vector import Vector
 from UM.Scene.Selection import Selection
 from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
 from UM.Operations.GroupedOperation import GroupedOperation
 from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
-from UM.Operations.RotateOperation import RotateOperation
 from UM.Operations.TranslateOperation import TranslateOperation
 
 import cura.CuraApplication

+ 5 - 5
cura/CuraApplication.py

@@ -1442,7 +1442,7 @@ class CuraApplication(QtApplication):
             if center is not None:
                 object_centers.append(center)
 
-        if object_centers and len(object_centers) > 0:
+        if object_centers:
             middle_x = sum([v.x for v in object_centers]) / len(object_centers)
             middle_y = sum([v.y for v in object_centers]) / len(object_centers)
             middle_z = sum([v.z for v in object_centers]) / len(object_centers)
@@ -1492,7 +1492,7 @@ class CuraApplication(QtApplication):
                 if center is not None:
                     object_centers.append(center)
 
-            if object_centers and len(object_centers) > 0:
+            if object_centers:
                 middle_x = sum([v.x for v in object_centers]) / len(object_centers)
                 middle_y = sum([v.y for v in object_centers]) / len(object_centers)
                 middle_z = sum([v.z for v in object_centers]) / len(object_centers)
@@ -1674,7 +1674,7 @@ class CuraApplication(QtApplication):
         extension = os.path.splitext(f)[1]
         extension = extension.lower()
         filename = os.path.basename(f)
-        if len(self._currently_loading_files) > 0:
+        if self._currently_loading_files:
             # If a non-slicable file is already being loaded, we prevent loading of any further non-slicable files
             if extension in self._non_sliceable_extensions:
                 message = Message(
@@ -1795,8 +1795,8 @@ class CuraApplication(QtApplication):
                 node.addDecorator(build_plate_decorator)
             build_plate_decorator.setBuildPlateNumber(target_build_plate)
 
-            op = AddSceneNodeOperation(node, scene.getRoot())
-            op.push()
+            operation = AddSceneNodeOperation(node, scene.getRoot())
+            operation.push()
 
             node.callDecoration("setActiveExtruder", default_extruder_id)
             scene.sceneChanged.emit(node)

+ 1 - 0
cura/CuraView.py

@@ -26,6 +26,7 @@ class CuraView(View):
     def mainComponent(self) -> QUrl:
         return self.getDisplayComponent("main")
 
+
     @pyqtProperty(QUrl, constant = True)
     def stageMenuComponent(self) -> QUrl:
         url = self.getDisplayComponent("menu")

+ 3 - 3
cura/LayerPolygon.py

@@ -1,10 +1,10 @@
 # Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
-
-from UM.Qt.QtApplication import QtApplication
-from typing import Any, Optional
 import numpy
 
+from typing import Optional
+
+from UM.Qt.QtApplication import QtApplication
 from UM.Logger import Logger
 
 

+ 2 - 2
cura/Machines/MachineNode.py

@@ -176,9 +176,9 @@ class MachineNode(ContainerNode):
 
         # Find the global qualities for this printer.
         global_qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.quality_definition, global_quality = "True")  # First try specific to this printer.
-        if len(global_qualities) == 0:  # This printer doesn't override the global qualities.
+        if not global_qualities:  # This printer doesn't override the global qualities.
             global_qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = "fdmprinter", global_quality = "True")  # Otherwise pick the global global qualities.
-            if len(global_qualities) == 0:  # There are no global qualities either?! Something went very wrong, but we'll not crash and properly fill the tree.
+            if not global_qualities:  # There are no global qualities either?! Something went very wrong, but we'll not crash and properly fill the tree.
                 global_qualities = [cura.CuraApplication.CuraApplication.getInstance().empty_quality_container.getMetaData()]
         for global_quality in global_qualities:
             self.global_qualities[global_quality["quality_type"]] = QualityNode(global_quality["id"], parent = self)

+ 1 - 1
cura/Machines/QualityNode.py

@@ -41,4 +41,4 @@ class QualityNode(ContainerNode):
                 self.intents[intent["id"]] = IntentNode(intent["id"], quality = self)
 
         self.intents["empty_intent"] = IntentNode("empty_intent", quality = self)
-        # Otherwise, there are no intents for global profiles.
+        # Otherwise, there are no intents for global profiles.

Some files were not shown because too many files changed in this diff