diff options
author | Ghostkeeper <rubend@tutanota.com> | 2018-11-14 15:41:23 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2018-11-14 15:41:23 +0300 |
commit | ae2b3124721c9c74730073d178c0ac1927819b1c (patch) | |
tree | 9587731e71adb92bd9d8cb06b1ed93dbc5ce82a8 /plugins/VersionUpgrade/VersionUpgrade34to35 | |
parent | fe66d15b9e1b615ac894daddf24e1a1aeecb2408 (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/VersionUpgrade34to35')
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py | 23 | ||||
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py | 9 |
2 files changed, 18 insertions, 14 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py b/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py index 9d59133036..88cc3ca420 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/VersionUpgrade34to35.py @@ -3,13 +3,14 @@ import configparser import io +from typing import Dict, List, Set, Tuple from UM.VersionUpgrade import VersionUpgrade -deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"} +deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"} # type: Set[str] -changed_settings = {'retraction_combing': 'noskin'} -updated_settings = {'retraction_combing': 'infill'} +changed_settings = {"retraction_combing": "noskin"} # type: Dict[str, str] +updated_settings = {"retraction_combing": "infill"} # type: Dict[str, str] _RENAMED_MATERIAL_PROFILES = { "dsm_arnitel2045_175_cartesio_0.25_mm": "dsm_arnitel2045_175_cartesio_0.25mm_thermoplastic_extruder", @@ -57,12 +58,11 @@ _RENAMED_MATERIAL_PROFILES = { "ultimaker_pva_cartesio_0.25_mm": "ultimaker_pva_cartesio_0.25mm_thermoplastic_extruder", "ultimaker_pva_cartesio_0.4_mm": "ultimaker_pva_cartesio_0.4mm_thermoplastic_extruder", "ultimaker_pva_cartesio_0.8_mm": "ultimaker_pva_cartesio_0.8mm_thermoplastic_extruder" -} +} # type: Dict[str, str] ## Upgrades configurations from the state they were in at version 3.4 to the # state they should be in at version 3.5. class VersionUpgrade34to35(VersionUpgrade): - ## Gets the version number from a CFG file in Uranium's 3.3 format. # # Since the format may change, this is implemented for the 3.3 format only @@ -74,7 +74,7 @@ class VersionUpgrade34to35(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. @@ -82,7 +82,7 @@ class VersionUpgrade34to35(VersionUpgrade): return format_version * 1000000 + setting_version ## Upgrades Preferences to have the new version number. - def upgradePreferences(self, serialized, filename): + def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -103,7 +103,7 @@ class VersionUpgrade34to35(VersionUpgrade): return [filename], [result.getvalue()] ## Upgrades stacks to have the new version number. - def upgradeStack(self, serialized, filename): + def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -121,7 +121,7 @@ class VersionUpgrade34to35(VersionUpgrade): ## Upgrades instance containers to have the new version # number. - def upgradeInstanceContainer(self, serialized, filename): + def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) @@ -147,7 +147,7 @@ class VersionUpgrade34to35(VersionUpgrade): parser.write(result) return [filename], [result.getvalue()] - def _resetConcentric3DInfillPattern(self, parser): + def _resetConcentric3DInfillPattern(self, parser: configparser.ConfigParser) -> None: if "values" not in parser: return @@ -161,5 +161,4 @@ class VersionUpgrade34to35(VersionUpgrade): if key not in parser["values"]: continue if parser["values"][key] == "concentric_3d": - del parser["values"][key] - + del parser["values"][key]
\ No newline at end of file diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py b/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py index 2ea74f6194..332bc827b9 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py @@ -1,11 +1,16 @@ # 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 VersionUpgrade34to35 +if TYPE_CHECKING: + from UM.Application import Application + upgrade = VersionUpgrade34to35.VersionUpgrade34to35() -def getMetaData(): +def getMetaData() -> Dict[str, Any]: return { "version_upgrade": { # From To Upgrade function @@ -52,5 +57,5 @@ def getMetaData(): } -def register(app): +def register(app: "Application") -> Dict[str, Any]: return { "version_upgrade": upgrade } |