0
$\begingroup$

I am working on a blender addon. After working with the addon enabled in the blender window. I start seeing the following bug in the console.

RuntimeError: class CONSOLE_OT_banner, function execute: incompatible return value , , Function.result expected a set, not a NoneType
Error: Python: RuntimeError: class CONSOLE_OT_banner, function execute: incompatible return value , , Function.result expected a set, not a NoneType

The error goes away if I delete the userpref.blend file and restart blender. Has anybody else faced this issue or have any suggestions to debug?

$\endgroup$
1
  • $\begingroup$ For more complicated issues, it will be helpful to post the code so others can point at the exact location of the problem. $\endgroup$ Commented Mar 14, 2024 at 20:29

1 Answer 1

1
$\begingroup$

Without looking at the full code I will make an educated guess. Don't forget to add return{'FINISHED'} at the bottom of your execute(self, context) function, like this:

def execute(self, context):
    # do something
    
    return {'FINISHED'}

When you don't specify a return value for a function, Python returns None by default, so I believe that to be the problem here. Don't forget to check out the Python templates that Blender offers in the Script Editor.

$\endgroup$
2
  • $\begingroup$ I am aware of return type and did check my code after your post. I always return {"FINISHED"} at the end of execute function. I am wondering what happens if my code in the execute fails. Would blender automatically return {"CANCELLED"} or other valid return value? Or I need to do error checking and return a valid value? $\endgroup$ Commented Mar 14, 2024 at 21:49
  • $\begingroup$ Well, the error above says specifically that None is being returned instead of a Set (like {'FINISHED'} OR {'CANCELLED'}. Using curly braces {} is how you define a Set in Python, so for some reason you never reach the correct return value. $\endgroup$ Commented Mar 15, 2024 at 0:09

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.