From 10f22f9c2572902edb6e0eea49ba58e1e241c7fd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 15 Jun 2018 15:09:19 +0200 Subject: [PATCH] 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. --- plugins/GCodeGzWriter/GCodeGzWriter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/GCodeGzWriter/GCodeGzWriter.py b/plugins/GCodeGzWriter/GCodeGzWriter.py index 06fafb5995..6ddecdb0bd 100644 --- a/plugins/GCodeGzWriter/GCodeGzWriter.py +++ b/plugins/GCodeGzWriter/GCodeGzWriter.py @@ -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