Fix Mypy warnings

CURA-6983
This commit is contained in:
Nino van Hooff 2020-01-13 09:57:35 +01:00
parent 6aba835c1c
commit 53115dc3b2
4 changed files with 11 additions and 9 deletions

View file

@ -1,3 +1,5 @@
from typing import Union
from cura import ApplicationMetadata, UltimakerCloudAuthentication

View file

@ -29,7 +29,7 @@ class DownloadPresenter:
self._scope = UltimakerCloudScope(app)
self._started = False
self._progress_message = None # type: Optional[Message]
self._progress_message = self._createProgressMessage()
self._progress = {} # type: Dict[str, Dict[str, Any]] # package_id, Dict
self._error = [] # type: List[str] # package_id
@ -57,7 +57,7 @@ class DownloadPresenter:
}
self._started = True
self._showProgressMessage()
self._progress_message.show()
def abort(self):
manager = HttpRequestManager.getInstance()
@ -70,15 +70,14 @@ class DownloadPresenter:
self.done.disconnectAll()
return DownloadPresenter(self._app)
def _showProgressMessage(self):
self._progress_message = Message(i18n_catalog.i18nc(
def _createProgressMessage(self) -> Message:
return Message(i18n_catalog.i18nc(
"@info:generic",
"\nSyncing..."),
lifetime = 0,
use_inactivity_timer=False,
progress = 0.0,
title = i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ))
self._progress_message.show()
def _onFinished(self, package_id: str, reply: QNetworkReply):
self._progress[package_id]["received"] = self._progress[package_id]["total"]
@ -110,7 +109,7 @@ class DownloadPresenter:
self._progress_message.setProgress(100.0 * (received / total)) # [0 .. 100] %
def _onError(self, package_id: str):
def _onError(self, package_id: str) -> None:
self._progress.pop(package_id)
self._error.append(package_id)
self._checkDone()
@ -125,3 +124,4 @@ class DownloadPresenter:
self._progress_message.hide()
self.done.emit(success_items, error_items)
return True

View file

@ -1,5 +1,5 @@
import os
from typing import Dict, Optional
from typing import Dict, Optional, List
from PyQt5.QtCore import QObject, pyqtSlot
@ -24,7 +24,7 @@ class LicensePresenter(QObject):
self.licenseAnswers = Signal()
self._current_package_idx = 0
self._package_models = None # type: Optional[Dict]
self._package_models = [] # type: List[Dict]
self._license_model = LicenseModel() # type: LicenseModel
self._app = app

View file

@ -70,7 +70,7 @@ class SyncOrchestrator(Extension):
self._license_presenter.present(plugin_path, success_items)
# Called when user has accepted / declined all licenses for the downloaded packages
def _onLicenseAnswers(self, answers: [Dict[str, Any]]):
def _onLicenseAnswers(self, answers: List[Dict[str, Any]]):
Logger.debug("Got license answers: {}", answers)
has_changes = False # True when at least one package is installed