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
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2018-11-14 15:41:23 +0300
committerGhostkeeper <rubend@tutanota.com>2018-11-14 15:41:23 +0300
commitae2b3124721c9c74730073d178c0ac1927819b1c (patch)
tree9587731e71adb92bd9d8cb06b1ed93dbc5ce82a8 /plugins/VersionUpgrade/VersionUpgrade26to27
parentfe66d15b9e1b615ac894daddf24e1a1aeecb2408 (diff)
Add typing for all version upgrade plug-ins
Hopefully we'll take this typing along when we next copy-paste the stuffs. Contributes to issue CURA-5936.
Diffstat (limited to 'plugins/VersionUpgrade/VersionUpgrade26to27')
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py13
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py11
2 files changed, 15 insertions, 9 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py
index dfa436e5bd..96307ca43c 100644
--- a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py
+++ b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py
@@ -3,6 +3,7 @@
import configparser #To parse the files we need to upgrade and write the new files.
import io #To serialise configparser output to a string.
+from typing import Dict, List, Tuple
from UM.VersionUpgrade import VersionUpgrade
@@ -61,7 +62,7 @@ _renamed_quality_profiles = {
"um3_bb0.8_TPU_Not_Supported_Quality": "um3_bb0.8_TPU_Fast_print",
"um3_bb0.8_TPU_Not_Supported_Superdraft_Quality": "um3_bb0.8_TPU_Superdraft_Print",
-}
+} # type: Dict[str, str]
## A collection of functions that convert the configuration of the user in Cura
# 2.6 to a configuration for Cura 2.7.
@@ -79,7 +80,7 @@ class VersionUpgrade26to27(VersionUpgrade):
# \raises ValueError The format of the version number in the file is
# incorrect.
# \raises KeyError The format of the file is incorrect.
- def getCfgVersion(self, serialised):
+ def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
@@ -90,7 +91,7 @@ class VersionUpgrade26to27(VersionUpgrade):
#
# \param serialised The serialised form of a preferences file.
# \param filename The name of the file to upgrade.
- def upgradePreferences(self, serialised, filename):
+ def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None)
parser.read_string(serialised)
@@ -117,8 +118,8 @@ class VersionUpgrade26to27(VersionUpgrade):
#
# \param serialised The serialised form of a container file.
# \param filename The name of the file to upgrade.
- def upgradeOtherContainer(self, serialised, filename):
- parser = configparser.ConfigParser(interpolation=None)
+ def upgradeOtherContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
+ parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised)
# Update version numbers
@@ -139,7 +140,7 @@ class VersionUpgrade26to27(VersionUpgrade):
#
# \param serialised The serialised form of a container stack.
# \param filename The name of the file to upgrade.
- def upgradeStack(self, serialised, filename):
+ def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised)
diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py b/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py
index 0e26ca8bbf..1952c9ceff 100644
--- a/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py
+++ b/plugins/VersionUpgrade/VersionUpgrade26to27/__init__.py
@@ -1,11 +1,16 @@
-# Copyright (c) 2017 Ultimaker B.V.
+# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
+from typing import Any, Dict, TYPE_CHECKING
+
from . import VersionUpgrade26to27
+if TYPE_CHECKING:
+ from UM.Application import Application
+
upgrade = VersionUpgrade26to27.VersionUpgrade26to27()
-def getMetaData():
+def getMetaData() -> Dict[str, Any]:
return {
"version_upgrade": {
# From To Upgrade function
@@ -59,5 +64,5 @@ def getMetaData():
}
}
-def register(app):
+def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade }