Skip to content

Rewrite ops as classes and fix __call__ signature #3

Description

@Mysteryem

Operators, as found in bpy.ops.<submodule>, are actually classes, instances of bpy.ops._BPyOpsSubModOp, which have functions poll, idname, idname_py and get_rna_type and property bl_options. (the real bpy.ops module containing the class is in scripts\modules\bpy\ops.py)

Additionally, the current signature for these operators (as functions) is actually incorrect because the positional-only arguments, override_context, execution_context and undo are optional (though must be in the provided order), e.g., override_context can be omitted when only providing execution_context or undo. The current function signature requires that override_context is provided if also providing execution_context or undo, which is incorrect.
When rewriting ops as classes, it might be possible to define the __call__ function with overloads for each valid combination of positional-only arguments, if not, the signature will have to start with *args and give up on type checking the optional, positional-only arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions