Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cura
diff options
context:
space:
mode:
authorJaime van Kessel <nallath@gmail.com>2020-01-10 18:37:46 +0300
committerJaime van Kessel <nallath@gmail.com>2020-01-10 18:37:46 +0300
commite74f049142811d4ed5ce6406bc0075fd4f7c68ee (patch)
tree3671ccf6f11aa946a78c54a513b0884c692a41b2 /cura
parentbb52ba6848dd8319a5cf10bd5e2eaba994f159a5 (diff)
Fix bunch of issues found by pylint
Diffstat (limited to 'cura')
-rw-r--r--cura/Arranging/Arrange.py4
-rw-r--r--cura/Arranging/ArrangeObjectsAllBuildPlatesJob.py4
-rwxr-xr-xcura/BuildVolume.py28
-rw-r--r--cura/CrashHandler.py2
-rw-r--r--cura/CuraActions.py4
-rwxr-xr-xcura/CuraApplication.py10
-rw-r--r--cura/CuraView.py1
-rw-r--r--cura/LayerPolygon.py6
-rw-r--r--cura/Machines/MachineNode.py4
-rw-r--r--cura/Machines/QualityNode.py2
-rw-r--r--cura/MultiplyObjectsJob.py10
-rw-r--r--cura/PreviewPass.py3
-rw-r--r--cura/PrinterOutput/PrinterOutputDevice.py2
-rw-r--r--cura/Scene/BlockSlicingDecorator.py5
-rw-r--r--cura/Scene/GCodeListDecorator.py4
-rw-r--r--cura/Settings/CuraContainerRegistry.py5
16 files changed, 50 insertions, 44 deletions
diff --git a/cura/Arranging/Arrange.py b/cura/Arranging/Arrange.py
index 8f7ba5ccfe..d6b8e44cea 100644
--- a/cura/Arranging/Arrange.py
+++ b/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
diff --git a/cura/Arranging/ArrangeObjectsAllBuildPlatesJob.py b/cura/Arranging/ArrangeObjectsAllBuildPlatesJob.py
index 89f613e180..7736efbeeb 100644
--- a/cura/Arranging/ArrangeObjectsAllBuildPlatesJob.py
+++ b/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
diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py
index aba94e8c60..d7ab18b09e 100755
--- a/cura/BuildVolume.py
+++ b/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")
diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py
index 6b33dc2d03..e72180887c 100644
--- a/cura/CrashHandler.py
+++ b/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):
diff --git a/cura/CuraActions.py b/cura/CuraActions.py
index b92abbe706..20c44c7916 100644
--- a/cura/CuraActions.py
+++ b/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
diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py
index d479b0fe18..f778cb0fab 100755
--- a/cura/CuraApplication.py
+++ b/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)
diff --git a/cura/CuraView.py b/cura/CuraView.py
index b358558dff..d594ea9571 100644
--- a/cura/CuraView.py
+++ b/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")
diff --git a/cura/LayerPolygon.py b/cura/LayerPolygon.py
index 353d195100..6bdd0d53d1 100644
--- a/cura/LayerPolygon.py
+++ b/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
diff --git a/cura/Machines/MachineNode.py b/cura/Machines/MachineNode.py
index cee71160d2..0974c3dca7 100644
--- a/cura/Machines/MachineNode.py
+++ b/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)
diff --git a/cura/Machines/QualityNode.py b/cura/Machines/QualityNode.py
index 45cd898db5..7696dfb117 100644
--- a/cura/Machines/QualityNode.py
+++ b/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. \ No newline at end of file
+ # Otherwise, there are no intents for global profiles.
diff --git a/cura/MultiplyObjectsJob.py b/cura/MultiplyObjectsJob.py
index 5c25f70336..134e579746 100644
--- a/cura/MultiplyObjectsJob.py
+++ b/cura/MultiplyObjectsJob.py
@@ -47,7 +47,7 @@ class MultiplyObjectsJob(Job):
nodes = []
not_fit_count = 0
-
+ found_solution_for_all = False
for node in self._objects:
# If object is part of a group, multiply group
current_node = node
@@ -66,7 +66,7 @@ class MultiplyObjectsJob(Job):
found_solution_for_all = True
arranger.resetLastPriority()
- for i in range(self._count):
+ for _ in range(self._count):
# We do place the nodes one by one, as we want to yield in between.
new_node = copy.deepcopy(node)
solution_found = False
@@ -98,10 +98,10 @@ class MultiplyObjectsJob(Job):
Job.yieldThread()
if nodes:
- op = GroupedOperation()
+ operation = GroupedOperation()
for new_node in nodes:
- op.addOperation(AddSceneNodeOperation(new_node, current_node.getParent()))
- op.push()
+ operation.addOperation(AddSceneNodeOperation(new_node, current_node.getParent()))
+ operation.push()
status_message.hide()
if not found_solution_for_all:
diff --git a/cura/PreviewPass.py b/cura/PreviewPass.py
index 58205ba708..da60db2d99 100644
--- a/cura/PreviewPass.py
+++ b/cura/PreviewPass.py
@@ -17,9 +17,6 @@ from cura.Scene.CuraSceneNode import CuraSceneNode
if TYPE_CHECKING:
from UM.View.GL.ShaderProgram import ShaderProgram
-
-MYPY = False
-if MYPY:
from UM.Scene.Camera import Camera
diff --git a/cura/PrinterOutput/PrinterOutputDevice.py b/cura/PrinterOutput/PrinterOutputDevice.py
index b05e76ad2e..0e0ad488b1 100644
--- a/cura/PrinterOutput/PrinterOutputDevice.py
+++ b/cura/PrinterOutput/PrinterOutputDevice.py
@@ -148,7 +148,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
@pyqtProperty(QObject, notify = printersChanged)
def activePrinter(self) -> Optional["PrinterOutputModel"]:
- if len(self._printers):
+ if self._printers:
return self._printers[0]
return None
diff --git a/cura/Scene/BlockSlicingDecorator.py b/cura/Scene/BlockSlicingDecorator.py
index d9c9e0ac5e..3f0d57a83f 100644
--- a/cura/Scene/BlockSlicingDecorator.py
+++ b/cura/Scene/BlockSlicingDecorator.py
@@ -9,4 +9,7 @@ class BlockSlicingDecorator(SceneNodeDecorator):
super().__init__()
def isBlockSlicing(self) -> bool:
- return True \ No newline at end of file
+ return True
+
+ def __deepcopy__(self, memo):
+ return BlockSlicingDecorator() \ No newline at end of file
diff --git a/cura/Scene/GCodeListDecorator.py b/cura/Scene/GCodeListDecorator.py
index 6c52fb89bf..b8db706db3 100644
--- a/cura/Scene/GCodeListDecorator.py
+++ b/cura/Scene/GCodeListDecorator.py
@@ -17,8 +17,8 @@ class GCodeListDecorator(SceneNodeDecorator):
def getGCodeList(self) -> List[str]:
return self._gcode_list
- def setGCodeList(self, list: List[str]) -> None:
- self._gcode_list = list
+ def setGCodeList(self, gcode_list: List[str]) -> None:
+ self._gcode_list = gcode_list
def __deepcopy__(self, memo) -> "GCodeListDecorator":
copied_decorator = GCodeListDecorator()
diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py
index f6028e9d4d..0ef09a1fac 100644
--- a/cura/Settings/CuraContainerRegistry.py
+++ b/cura/Settings/CuraContainerRegistry.py
@@ -15,7 +15,6 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.ContainerStack import ContainerStack
from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.SettingInstance import SettingInstance
-from UM.Application import Application
from UM.Logger import Logger
from UM.Message import Message
from UM.Platform import Platform
@@ -176,7 +175,7 @@ class CuraContainerRegistry(ContainerRegistry):
if not file_name:
return { "status": "error", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "Failed to import profile from <filename>{0}</filename>: {1}", file_name, "Invalid path")}
- global_stack = Application.getInstance().getGlobalContainerStack()
+ global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if not global_stack:
return {"status": "error", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "Can't import profile from <filename>{0}</filename> before a printer is added.", file_name)}
container_tree = ContainerTree.getInstance()
@@ -384,7 +383,7 @@ class CuraContainerRegistry(ContainerRegistry):
if not quality_type:
return catalog.i18nc("@info:status", "Profile is missing a quality type.")
- global_stack = Application.getInstance().getGlobalContainerStack()
+ global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if global_stack is None:
return None
definition_id = ContainerTree.getInstance().machines[global_stack.definition.getId()].quality_definition