mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Better type checking and handling of optionals
Adds type checking here and there to catch such errors in the future. This makes it handle the optional fields of this model better. Contributes to issue CURA-8730.
This commit is contained in:
parent
9d4599df39
commit
9674c54efb
2 changed files with 13 additions and 11 deletions
|
@ -40,7 +40,7 @@ class ClusterPrintJobStatus(BaseModel):
|
|||
configuration_changes_required: List[
|
||||
Union[Dict[str, Any], ClusterPrintJobConfigurationChange]] = None,
|
||||
build_plate: Union[Dict[str, Any], ClusterBuildPlate] = None,
|
||||
compatible_machine_families: List[str] = None,
|
||||
compatible_machine_families: Optional[List[str]] = None,
|
||||
impediments_to_printing: List[Union[Dict[str, Any], ClusterPrintJobImpediment]] = None,
|
||||
preview_url: Optional[str] = None,
|
||||
**kwargs) -> None:
|
||||
|
@ -97,7 +97,7 @@ class ClusterPrintJobStatus(BaseModel):
|
|||
configuration_changes_required) \
|
||||
if configuration_changes_required else []
|
||||
self.build_plate = self.parseModel(ClusterBuildPlate, build_plate) if build_plate else None
|
||||
self.compatible_machine_families = compatible_machine_families if compatible_machine_families else []
|
||||
self.compatible_machine_families = compatible_machine_families if compatible_machine_families is not None else []
|
||||
self.impediments_to_printing = self.parseModels(ClusterPrintJobImpediment, impediments_to_printing) \
|
||||
if impediments_to_printing else []
|
||||
|
||||
|
@ -130,8 +130,10 @@ class ClusterPrintJobStatus(BaseModel):
|
|||
|
||||
model.updateConfiguration(self._createConfigurationModel())
|
||||
model.updateTimeTotal(self.time_total)
|
||||
model.updateTimeElapsed(self.time_elapsed)
|
||||
model.updateOwner(self.owner)
|
||||
if self.time_elapsed is not None:
|
||||
model.updateTimeElapsed(self.time_elapsed)
|
||||
if self.owner is not None:
|
||||
model.updateOwner(self.owner)
|
||||
model.updateState(self.status)
|
||||
model.setCompatibleMachineFamilies(self.compatible_machine_families)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue