[Blender] Warning: class CLASS_NAME contains a property which should be an annotation!
Warning Detail
When I install my custom addon in Blender2.80, the warning “class CLASS_NAME contains a property which should be an annotation!” occured. the class CLASS_NAME is an operator class that inherits bpy.types.Operator. And the class contains bpy.props properties as below.
class MY_OT_import_file(bpy.types.Operator):
bl_idname = "my.import_file"
bl_label = "My Import file"
bl_description = "Custom import addon"
bl_options = {'REGISTER', 'UNDO'}
filepath = bpy.props.StringProperty(default="",subtype="FILE_PATH")
def execute(self, context):
...Cause
Reference: Blender 2.80: Addon API
Classes that contain properties from
from Blender 2.80: Addon APIbpy.propsnow use Python’s type annotations (see PEP 526) and should be assigned using a single colon:in Blender 2.8x instead of equals=as was done in 2.7x
Correction
Use annotation in the class where warning occurred to set properties.
class MY_OT_import_file(bpy.types.Operator):
bl_idname = "my.import_file"
bl_label = "My Import file"
bl_description = "Custom import addon"
bl_options = {'REGISTER', 'UNDO'}
filepath : bpy.props.StringProperty(default="",subtype="FILE_PATH")
def execute(self, context):
...