Fixed typing issues for configuredConnectionTypes

CURA-6159
This commit is contained in:
Jaime van Kessel 2019-01-30 17:17:46 +01:00
parent 949a687a07
commit 87070aefce

View file

@ -77,27 +77,27 @@ class GlobalStack(CuraContainerStack):
# If we can't get a network connection, but it is configured to have one, # If we can't get a network connection, but it is configured to have one,
# we can display a different icon to indicate the difference. # we can display a different icon to indicate the difference.
@pyqtProperty("QVariantList", notify=configuredConnectionTypesChanged) @pyqtProperty("QVariantList", notify=configuredConnectionTypesChanged)
def configuredConnectionTypes(self): def configuredConnectionTypes(self) -> List[int]:
# Requesting it from the metadata actually gets them as strings (as that's what you get from serializing). # Requesting it from the metadata actually gets them as strings (as that's what you get from serializing).
# But we do want them returned as a list of ints (so the rest of the code can directly compare) # But we do want them returned as a list of ints (so the rest of the code can directly compare)
connection_types = self.getMetaDataEntry("connection_type", "").split(",") connection_types = self.getMetaDataEntry("connection_type", "").split(",")
return [int(connection_type) for connection_type in connection_types if connection_type != ""] return [int(connection_type) for connection_type in connection_types if connection_type != ""]
## \sa configuredConnectionTypes ## \sa configuredConnectionTypes
def addConfiguredConnectionType(self, connection_type): def addConfiguredConnectionType(self, connection_type: int) -> None:
configured_connection_types = self.configuredConnectionTypes configured_connection_types = self.configuredConnectionTypes
if connection_type not in configured_connection_types: if connection_type not in configured_connection_types:
# Store the values as a string. # Store the values as a string.
configured_connection_types.append(str(connection_type)) configured_connection_types.append(connection_type)
self.setMetaDataEntry("connection_type", ",".join(configured_connection_types)) self.setMetaDataEntry("connection_type", ",".join([str(c_type) for c_type in configured_connection_types]))
## \sa configuredConnectionTypes ## \sa configuredConnectionTypes
def removeConfiguredConnectionType(self, connection_type): def removeConfiguredConnectionType(self, connection_type: int) -> None:
configured_connection_types = self.configuredConnectionTypes configured_connection_types = self.configuredConnectionTypes
if connection_type in self.configured_connection_types: if connection_type in self.configured_connection_types:
# Store the values as a string. # Store the values as a string.
configured_connection_types.remove(str(connection_type)) configured_connection_types.remove(connection_type)
self.setMetaDataEntry("connection_type", ",".join(configured_connection_types)) self.setMetaDataEntry("connection_type", ",".join([str(c_type) for c_type in configured_connection_types]))
@classmethod @classmethod
def getConfigurationTypeFromSerialized(cls, serialized: str) -> Optional[str]: def getConfigurationTypeFromSerialized(cls, serialized: str) -> Optional[str]: