mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 06:03:57 -06:00
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.
This commit is contained in:
parent
fe66d15b9e
commit
ae2b312472
21 changed files with 200 additions and 150 deletions
|
@ -3,17 +3,17 @@
|
|||
|
||||
import configparser #To parse preference files.
|
||||
import io #To serialise the preference files afterwards.
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
|
||||
|
||||
_renamed_settings = {
|
||||
"infill_hollow": "infill_support_enabled"
|
||||
}
|
||||
} # type: Dict[str, str]
|
||||
|
||||
## Upgrades configurations from the state they were in at version 3.3 to the
|
||||
# state they should be in at version 3.4.
|
||||
class VersionUpgrade33to34(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
|
||||
|
@ -25,7 +25,7 @@ class VersionUpgrade33to34(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.
|
||||
|
@ -34,7 +34,7 @@ class VersionUpgrade33to34(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)
|
||||
|
||||
|
|
|
@ -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 VersionUpgrade33to34
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from UM.Application import Application
|
||||
|
||||
upgrade = VersionUpgrade33to34.VersionUpgrade33to34()
|
||||
|
||||
def getMetaData():
|
||||
def getMetaData() -> Dict[str, Any]:
|
||||
return {
|
||||
"version_upgrade": {
|
||||
# From To Upgrade function
|
||||
|
@ -35,5 +40,5 @@ def getMetaData():
|
|||
}
|
||||
|
||||
|
||||
def register(app):
|
||||
def register(app: "Application") -> Dict[str, Any]:
|
||||
return { "version_upgrade": upgrade }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue