diff options
author | Ghostkeeper <rubend@tutanota.com> | 2018-11-14 15:56:46 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2018-11-14 15:56:46 +0300 |
commit | 8ec7d6dba3b79dc88c9496185c6e49000740018a (patch) | |
tree | 8a889a9dc14919a5a18b3dfb244ed81d8738b694 /plugins/VersionUpgrade/VersionUpgrade21to22 | |
parent | b67d8d410343490b96357def995adb3a8f0d198f (diff) |
Fix type issues in old version upgrade plug-ins
The one actual change was this: To give a KeyError when stuff can't be found in a dictionary, rather than returning None there and then getting a TypeError later.
Contributes to issue CURA-5936.
Diffstat (limited to 'plugins/VersionUpgrade/VersionUpgrade21to22')
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py | 10 | ||||
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index a947114595..478f955e49 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -4,7 +4,7 @@ import configparser #To read config files. import io #To write config files to strings as if they were files. import os.path #To get the path to write new user profiles to. -from typing import List, Optional, Tuple +from typing import Dict, List, Optional, Set, Tuple import urllib #To serialise the user container file name properly. import UM.VersionUpgrade #To indicate that a file is of incorrect format. @@ -33,7 +33,7 @@ class MachineInstance: # \param serialised A string with the contents of a machine instance file, # without extension. # \param filename The supposed file name of this machine instance. - def __init__(self, serialised: str, filename: str) -> str: + def __init__(self, serialised: str, filename: str) -> None: self._filename = filename config = configparser.ConfigParser(interpolation = None) @@ -54,11 +54,11 @@ class MachineInstance: self._type_name = config.get("general", "type") self._variant_name = config.get("general", "variant", fallback = "empty_variant") self._name = config.get("general", "name", fallback = "") - self._key = config.get("general", "key", fallback = None) + self._key = config.get("general", "key", fallback = "") self._active_profile_name = config.get("general", "active_profile", fallback = "empty_quality") self._active_material_name = config.get("general", "material", fallback = "empty_material") - self._machine_setting_overrides = {} + self._machine_setting_overrides = {} # type: Dict[str, str] for key, value in config["machine_settings"].items(): self._machine_setting_overrides[key] = value @@ -109,7 +109,7 @@ class MachineInstance: version_upgrade_manager = UM.VersionUpgradeManager.VersionUpgradeManager.getInstance() user_version_to_paths_dict = version_upgrade_manager.getStoragePaths("user") - paths_set = set() + paths_set = set() # type: Set[str] for paths in user_version_to_paths_dict.values(): paths_set |= paths diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py index 51e4b617e8..953837b863 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/Preferences.py @@ -59,11 +59,11 @@ class Preferences: #Translate the setting names in the visible settings. if self._config.has_section("machines") and self._config.has_option("machines", "setting_visibility"): visible_settings = self._config.get("machines", "setting_visibility") - visible_settings = visible_settings.split(",") + visible_settings_list = visible_settings.split(",") import VersionUpgrade21to22 #Import here to prevent a circular dependency. - visible_settings = [VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettingName(setting_name) - for setting_name in visible_settings] - visible_settings = ",".join(visible_settings) + visible_settings_list = [VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettingName(setting_name) + for setting_name in visible_settings_list] + visible_settings = ",".join(visible_settings_list) self._config.set("machines", "setting_visibility", value = visible_settings) #Translate the active_instance key. |