Fix typing issues

CURA-6005
This commit is contained in:
Lipu Fei 2018-12-12 10:35:36 +01:00
parent 2275e5c71f
commit 8c07a6e89b
4 changed files with 11 additions and 10 deletions

View file

@ -3,7 +3,7 @@ import base64
import hashlib import hashlib
from datetime import datetime from datetime import datetime
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from typing import Optional, List, Dict from typing import Any, Optional, List, Dict
import requests import requests
@ -34,7 +34,7 @@ class DriveApiService:
"""Create a new instance of the Drive API service and set the cura_api object.""" """Create a new instance of the Drive API service and set the cura_api object."""
self._cura_api = cura_api self._cura_api = cura_api
def getBackups(self) -> List[Dict[str, any]]: def getBackups(self) -> List[Dict[str, Any]]:
"""Get all backups from the API.""" """Get all backups from the API."""
access_token = self._cura_api.account.accessToken access_token = self._cura_api.account.accessToken
if not access_token: if not access_token:
@ -85,7 +85,7 @@ class DriveApiService:
else: else:
self.onCreatingStateChanged.emit(is_creating=False) self.onCreatingStateChanged.emit(is_creating=False)
def restoreBackup(self, backup: Dict[str, any]) -> None: def restoreBackup(self, backup: Dict[str, Any]) -> None:
""" """
Restore a previously exported backup from cloud storage. Restore a previously exported backup from cloud storage.
:param backup: A dict containing an entry from the API list response. :param backup: A dict containing an entry from the API list response.
@ -157,7 +157,7 @@ class DriveApiService:
return False return False
return True return True
def _requestBackupUpload(self, backup_metadata: Dict[str, any], backup_size: int) -> Optional[str]: def _requestBackupUpload(self, backup_metadata: Dict[str, Any], backup_size: int) -> Optional[str]:
""" """
Request a backup upload slot from the API. Request a backup upload slot from the API.
:param backup_metadata: A dict containing some meta data about the backup. :param backup_metadata: A dict containing some meta data about the backup.

View file

@ -70,7 +70,8 @@ class DrivePluginExtension(QObject, Extension):
if not self._drive_window: if not self._drive_window:
self._drive_window = self.createDriveWindow() self._drive_window = self.createDriveWindow()
self.refreshBackups() self.refreshBackups()
self._drive_window.show() if self._drive_window:
self._drive_window.show()
def createDriveWindow(self) -> Optional["QObject"]: def createDriveWindow(self) -> Optional["QObject"]:
""" """

View file

@ -14,14 +14,14 @@ class UploadBackupJob(Job):
As it can take longer than some other tasks, we schedule this using a Cura Job. As it can take longer than some other tasks, we schedule this using a Cura Job.
""" """
def __init__(self, signed_upload_url: str, backup_zip: bytes): def __init__(self, signed_upload_url: str, backup_zip: bytes) -> None:
super().__init__() super().__init__()
self._signed_upload_url = signed_upload_url self._signed_upload_url = signed_upload_url
self._backup_zip = backup_zip self._backup_zip = backup_zip
self._upload_success = False self._upload_success = False
self.backup_upload_error_message = "" self.backup_upload_error_message = ""
def run(self): def run(self) -> None:
Message(Settings.translatable_messages["uploading_backup"], title = Settings.MESSAGE_TITLE, Message(Settings.translatable_messages["uploading_backup"], title = Settings.MESSAGE_TITLE,
lifetime = 10).show() lifetime = 10).show()

View file

@ -1,5 +1,5 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
from typing import List, Dict from typing import Any, List, Dict
from UM.Qt.ListModel import ListModel from UM.Qt.ListModel import ListModel
@ -11,7 +11,7 @@ class BackupListModel(ListModel):
The BackupListModel transforms the backups data that came from the server so it can be served to the Qt UI. The BackupListModel transforms the backups data that came from the server so it can be served to the Qt UI.
""" """
def __init__(self, parent=None): def __init__(self, parent = None) -> None:
super().__init__(parent) super().__init__(parent)
self.addRoleName(Qt.UserRole + 1, "backup_id") self.addRoleName(Qt.UserRole + 1, "backup_id")
self.addRoleName(Qt.UserRole + 2, "download_url") self.addRoleName(Qt.UserRole + 2, "download_url")
@ -19,7 +19,7 @@ class BackupListModel(ListModel):
self.addRoleName(Qt.UserRole + 4, "md5_hash") self.addRoleName(Qt.UserRole + 4, "md5_hash")
self.addRoleName(Qt.UserRole + 5, "data") self.addRoleName(Qt.UserRole + 5, "data")
def loadBackups(self, data: List[Dict[str, any]]) -> None: def loadBackups(self, data: List[Dict[str, Any]]) -> None:
""" """
Populate the model with server data. Populate the model with server data.
:param data: :param data: