mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Fix incorrect typing and issues caused by typing
This commit is contained in:
parent
09742f0cf5
commit
9af71f2888
6 changed files with 15 additions and 15 deletions
|
@ -9,7 +9,7 @@ from cura.CuraApplication import CuraApplication
|
|||
|
||||
from enum import IntEnum
|
||||
from threading import Thread
|
||||
from typing import Any
|
||||
from typing import Union
|
||||
|
||||
class FirmwareUpdater(QObject):
|
||||
firmwareProgressChanged = pyqtSignal()
|
||||
|
@ -25,7 +25,7 @@ class FirmwareUpdater(QObject):
|
|||
self._firmware_progress = 0
|
||||
self._firmware_update_state = FirmwareUpdateState.idle
|
||||
|
||||
def updateFirmware(self, file: Any[str, QUrl]) -> None:
|
||||
def updateFirmware(self, file: Union[str, QUrl]) -> None:
|
||||
# the file path could be url-encoded.
|
||||
if file.startswith("file://"):
|
||||
self._firmware_location = QUrl(file).toLocalFile()
|
||||
|
@ -60,7 +60,7 @@ class FirmwareUpdater(QObject):
|
|||
return self._firmware_progress
|
||||
|
||||
@pyqtProperty(int, notify=firmwareUpdateStateChanged)
|
||||
def firmwareUpdateState(self) -> FirmwareUpdateState:
|
||||
def firmwareUpdateState(self) -> "FirmwareUpdateState":
|
||||
return self._firmware_update_state
|
||||
|
||||
def setFirmwareUpdateState(self, state) -> None:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Union
|
||||
|
||||
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
|
||||
from PyQt5.QtCore import QTimer
|
||||
|
@ -109,7 +109,7 @@ class GenericOutputController(PrinterOutputController):
|
|||
self.setTargetBedTemperature(self._preheat_printer, 0)
|
||||
self._preheat_printer.updateIsPreheating(False)
|
||||
|
||||
def setTargetHotendTemperature(self, printer: "PrinterOutputModel", position: int, temperature: int):
|
||||
def setTargetHotendTemperature(self, printer: "PrinterOutputModel", position: int, temperature: Union[int, float]) -> None:
|
||||
self._output_device.sendCommand("M104 S%s T%s" % (temperature, position))
|
||||
|
||||
def _onTargetHotendTemperatureChanged(self):
|
||||
|
|
|
@ -91,7 +91,7 @@ class PrintJobOutputModel(QObject):
|
|||
def assignedPrinter(self):
|
||||
return self._assigned_printer
|
||||
|
||||
def updateAssignedPrinter(self, assigned_printer: Optional[PrinterOutputModel]):
|
||||
def updateAssignedPrinter(self, assigned_printer: Optional["PrinterOutputModel"]):
|
||||
if self._assigned_printer != assigned_printer:
|
||||
old_printer = self._assigned_printer
|
||||
self._assigned_printer = assigned_printer
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
from UM.Logger import Logger
|
||||
from UM.Signal import Signal
|
||||
|
||||
from typing import Any
|
||||
from typing import Union
|
||||
|
||||
MYPY = False
|
||||
if MYPY:
|
||||
|
@ -15,7 +15,7 @@ if MYPY:
|
|||
|
||||
|
||||
class PrinterOutputController:
|
||||
def __init__(self, output_device: PrinterOutputDevice) -> None:
|
||||
def __init__(self, output_device: "PrinterOutputDevice") -> None:
|
||||
self.can_pause = True
|
||||
self.can_abort = True
|
||||
self.can_pre_heat_bed = True
|
||||
|
@ -25,7 +25,7 @@ class PrinterOutputController:
|
|||
self.can_update_firmware = False
|
||||
self._output_device = output_device
|
||||
|
||||
def setTargetHotendTemperature(self, printer: "PrinterOutputModel", extruder: "ExtruderOutputModel", temperature: Any[int, float]) -> None:
|
||||
def setTargetHotendTemperature(self, printer: "PrinterOutputModel", position: int, temperature: Union[int, float]) -> None:
|
||||
Logger.log("w", "Set target hotend temperature not implemented in controller")
|
||||
|
||||
def setTargetBedTemperature(self, printer: "PrinterOutputModel", temperature: int) -> None:
|
||||
|
|
|
@ -172,7 +172,7 @@ class PrinterOutputModel(QObject):
|
|||
def cancelPreheatBed(self) -> None:
|
||||
self._controller.cancelPreheatBed(self)
|
||||
|
||||
def getController(self) -> PrinterOutputController:
|
||||
def getController(self) -> "PrinterOutputController":
|
||||
return self._controller
|
||||
|
||||
@pyqtProperty(str, notify=nameChanged)
|
||||
|
@ -205,7 +205,7 @@ class PrinterOutputModel(QObject):
|
|||
self._controller.setTargetBedTemperature(self, temperature)
|
||||
self.updateTargetBedTemperature(temperature)
|
||||
|
||||
def updateActivePrintJob(self, print_job: Optional[PrintJobOutputModel]) -> None:
|
||||
def updateActivePrintJob(self, print_job: Optional["PrintJobOutputModel"]) -> None:
|
||||
if self._active_print_job != print_job:
|
||||
old_print_job = self._active_print_job
|
||||
|
||||
|
@ -223,14 +223,14 @@ class PrinterOutputModel(QObject):
|
|||
self.stateChanged.emit()
|
||||
|
||||
@pyqtProperty(QObject, notify = activePrintJobChanged)
|
||||
def activePrintJob(self) -> Optional[PrintJobOutputModel]:
|
||||
def activePrintJob(self) -> Optional["PrintJobOutputModel"]:
|
||||
return self._active_print_job
|
||||
|
||||
@pyqtProperty(str, notify=stateChanged)
|
||||
def state(self) -> str:
|
||||
return self._printer_state
|
||||
|
||||
@pyqtProperty(int, notify = bedTemperatureChanged)
|
||||
@pyqtProperty(int, notify=bedTemperatureChanged)
|
||||
def bedTemperature(self) -> int:
|
||||
return self._bed_temperature
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from serial import Serial, SerialException, SerialTimeoutException
|
|||
from threading import Thread, Event
|
||||
from time import time, sleep
|
||||
from queue import Queue
|
||||
from typing import Union, Optional, List, cast, Any
|
||||
from typing import Union, Optional, List, cast
|
||||
|
||||
import re
|
||||
import functools # Used for reduce
|
||||
|
@ -99,7 +99,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
application.triggerNextExitCheck()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def updateFirmware(self, file: Any[str, QUrl]) -> None:
|
||||
def updateFirmware(self, file: Union[str, QUrl]) -> None:
|
||||
self._firmware_updater.updateFirmware(file)
|
||||
|
||||
## Reset USB device settings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue