STAR-322: Fixing style errors

This commit is contained in:
Daniel Schiavini 2018-12-11 11:56:36 +01:00
parent 7668801564
commit d54fc4182b
15 changed files with 69 additions and 72 deletions

View file

@ -3,7 +3,7 @@
import json
import os
import urllib.parse
from typing import Dict, TYPE_CHECKING, Set
from typing import Dict, TYPE_CHECKING, Set, Optional
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
@ -151,7 +151,7 @@ class SendMaterialJob(Job):
# \return a dictionary of ClusterMaterial objects by GUID
# \throw KeyError Raised when on of the materials does not include a valid guid
@classmethod
def _parseReply(cls, reply: QNetworkReply) -> Dict[str, ClusterMaterial]:
def _parseReply(cls, reply: QNetworkReply) -> Optional[Dict[str, ClusterMaterial]]:
try:
remote_materials = json.loads(reply.readAll().data().decode("utf-8"))
return {material["guid"]: ClusterMaterial(**material) for material in remote_materials}
@ -163,6 +163,7 @@ class SendMaterialJob(Job):
Logger.log("e", "Request material storage on printer: Printer's answer had an incorrect value.")
except TypeError:
Logger.log("e", "Request material storage on printer: Printer's answer was missing a required value.")
return None
## Retrieves a list of local materials
#
@ -184,7 +185,8 @@ class SendMaterialJob(Job):
local_material = LocalMaterial(**material)
if local_material.GUID not in result or \
local_material.version > result.get(local_material.GUID).version:
local_material.GUID not in result or \
local_material.version > result[local_material.GUID].version:
result[local_material.GUID] = local_material
except KeyError: