Cast result of getPluginObject to the plug-in type it implements

We know for sure what the type of that plug-in is, only we can't import that type because it's a plug-in. We can (and did) import the plug-in type object MeshWriter though.

Contributes to issue CURA-5330.
This commit is contained in:
Ghostkeeper 2018-06-15 15:09:19 +02:00
parent e957f7b650
commit 10f22f9c25
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -3,7 +3,7 @@
import gzip
from io import StringIO, BufferedIOBase #To write the g-code to a temporary buffer, and for typing.
from typing import List
from typing import cast, List
from UM.Logger import Logger
from UM.Mesh.MeshWriter import MeshWriter #The class we're extending/implementing.
@ -32,7 +32,7 @@ class GCodeGzWriter(MeshWriter):
#Get the g-code from the g-code writer.
gcode_textio = StringIO() #We have to convert the g-code into bytes.
success = PluginRegistry.getInstance().getPluginObject("GCodeWriter").write(gcode_textio, None)
success = cast(MeshWriter, PluginRegistry.getInstance().getPluginObject("GCodeWriter")).write(gcode_textio, None)
if not success: #Writing the g-code failed. Then I can also not write the gzipped g-code.
return False