Add some missing typing

This commit is contained in:
Jaime van Kessel 2020-01-10 14:25:35 +01:00
parent 3e07105edf
commit 81b33b8649
No known key found for this signature in database
GPG key ID: 3710727397403C91
18 changed files with 73 additions and 59 deletions

View file

@ -2,12 +2,16 @@
# Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import QTimer
from typing import Any, TYPE_CHECKING
from UM.Logger import Logger
if TYPE_CHECKING:
from cura.CuraApplication import CuraApplication
class AutoSave:
def __init__(self, application):
def __init__(self, application: "CuraApplication") -> None:
self._application = application
self._application.getPreferences().preferenceChanged.connect(self._triggerTimer)
@ -22,14 +26,14 @@ class AutoSave:
self._enabled = True
self._saving = False
def initialize(self):
def initialize(self) -> None:
# only initialise if the application is created and has started
self._change_timer.timeout.connect(self._onTimeout)
self._application.globalContainerStackChanged.connect(self._onGlobalStackChanged)
self._onGlobalStackChanged()
self._triggerTimer()
def _triggerTimer(self, *args):
def _triggerTimer(self, *args: Any) -> None:
if not self._saving:
self._change_timer.start()
@ -40,7 +44,7 @@ class AutoSave:
else:
self._change_timer.stop()
def _onGlobalStackChanged(self):
def _onGlobalStackChanged(self) -> None:
if self._global_stack:
self._global_stack.propertyChanged.disconnect(self._triggerTimer)
self._global_stack.containersChanged.disconnect(self._triggerTimer)
@ -51,7 +55,7 @@ class AutoSave:
self._global_stack.propertyChanged.connect(self._triggerTimer)
self._global_stack.containersChanged.connect(self._triggerTimer)
def _onTimeout(self):
def _onTimeout(self) -> None:
self._saving = True # To prevent the save process from triggering another autosave.
Logger.log("d", "Autosaving preferences, instances and profiles")