Cleanup: unused args/vars/imports in bl_operators
authorCampbell Barton <ideasman42@gmail.com>
Wed, 8 May 2019 23:15:01 +0000 (09:15 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 9 May 2019 02:42:05 +0000 (12:42 +1000)
20 files changed:
release/scripts/startup/bl_operators/add_mesh_torus.py
release/scripts/startup/bl_operators/anim.py
release/scripts/startup/bl_operators/clip.py
release/scripts/startup/bl_operators/constraint.py
release/scripts/startup/bl_operators/file.py
release/scripts/startup/bl_operators/freestyle.py
release/scripts/startup/bl_operators/image.py
release/scripts/startup/bl_operators/mask.py
release/scripts/startup/bl_operators/object.py
release/scripts/startup/bl_operators/object_quick_effects.py
release/scripts/startup/bl_operators/object_randomize_transform.py
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_operators/rigidbody.py
release/scripts/startup/bl_operators/userpref.py
release/scripts/startup/bl_operators/uvcalc_follow_active.py
release/scripts/startup/bl_operators/uvcalc_lightmap.py
release/scripts/startup/bl_operators/uvcalc_smart_project.py
release/scripts/startup/bl_operators/vertexpaint_dirt.py
release/scripts/startup/bl_operators/view3d.py
release/scripts/startup/bl_operators/wm.py

index e449512..a22161f 100644 (file)
@@ -130,7 +130,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
     bl_label = "Add Torus"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
 
-    def mode_update_callback(self, context):
+    def mode_update_callback(self, _context):
         if self.mode == 'EXT_INT':
             self.abso_major_rad = self.major_radius + self.minor_radius
             self.abso_minor_rad = self.major_radius - self.minor_radius
@@ -196,7 +196,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
         default=True,
     )
 
-    def draw(self, context):
+    def draw(self, _context):
         layout = self.layout
 
         col = layout.column(align=True)
@@ -241,7 +241,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
             col.label(text="Interior Radius")
             col.prop(self, "abso_minor_rad", text="")
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         object_utils.object_add_grid_scale_apply_operator(self, context)
         return self.execute(context)
 
index 4f2642b..1470aed 100644 (file)
@@ -191,7 +191,7 @@ class ANIM_OT_keying_set_export(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
@@ -285,7 +285,7 @@ class NLA_OT_bake(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         scene = context.scene
         self.frame_start = scene.frame_start
         self.frame_end = scene.frame_end
@@ -309,10 +309,10 @@ class ClearUselessActions(Operator):
     )
 
     @classmethod
-    def poll(cls, context):
+    def poll(cls, _context):
         return bool(bpy.data.actions)
 
-    def execute(self, context):
+    def execute(self, _context):
         removed = 0
 
         for action in bpy.data.actions:
index 87c103e..664684c 100644 (file)
@@ -906,7 +906,7 @@ class CLIP_OT_setup_tracking_scene(Operator):
         return None
 
     @staticmethod
-    def _createLight(scene):
+    def _createLight():
         light = bpy.data.lights.new(name="Light", type='POINT')
         lightob = bpy.data.objects.new(name="Light", object_data=light)
 
@@ -951,7 +951,7 @@ class CLIP_OT_setup_tracking_scene(Operator):
 
         # Create sample light if there is no lights in the scene.
         if not has_light:
-            light = self._createLight(scene)
+            light = self._createLight()
             fg_coll.objects.link(light)
             bg_coll.objects.link(light)
 
index 811218f..2131229 100644 (file)
@@ -18,7 +18,6 @@
 
 # <pep8-80 compliant>
 
-import bpy
 from bpy.types import (
     Operator,
 )
index 5a127cf..43fbd38 100644 (file)
@@ -92,7 +92,7 @@ class WM_OT_previews_batch_generate(Operator):
         description="Keep a backup (.blend1) version of the files when saving with generated previews",
     )
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         context.window_manager.fileselect_add(self)
         return {'RUNNING_MODAL'}
 
@@ -202,7 +202,7 @@ class WM_OT_previews_batch_clear(Operator):
         description="Keep a backup (.blend1) version of the files when saving with cleared previews",
     )
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         context.window_manager.fileselect_add(self)
         return {'RUNNING_MODAL'}
 
@@ -291,7 +291,7 @@ class WM_OT_blend_strings_utf8_validate(Operator):
                     changed |= self.validate_strings(it, done_items)
         return changed
 
-    def execute(self, context):
+    def execute(self, _context):
         changed = False
         done_items = set()
         for prop in bpy.data.bl_rna.properties:
index 7196c53..b600df8 100644 (file)
@@ -212,13 +212,13 @@ class SCENE_OT_freestyle_module_open(bpy.types.Operator):
         view_layer = context.view_layer
         return view_layer and view_layer.freestyle_settings.mode == 'SCRIPT'
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         self.freestyle_module = context.freestyle_module
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
 
-    def execute(self, context):
+    def execute(self, _context):
         text = bpy.data.texts.load(self.filepath, self.make_internal)
         self.freestyle_module.script = text
         return {'FINISHED'}
index d07546d..4f0b574 100644 (file)
@@ -89,7 +89,7 @@ class EditExternally(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         import os
         sd = context.space_data
         try:
@@ -121,7 +121,7 @@ class SaveDirty(Operator):
     bl_label = "Save Dirty"
     bl_options = {'REGISTER', 'UNDO'}
 
-    def execute(self, context):
+    def execute(self, _context):
         unique_paths = set()
         for image in bpy.data.images:
             if image.is_dirty:
@@ -227,7 +227,7 @@ class ProjectApply(Operator):
     bl_label = "Project Apply"
     bl_options = {'REGISTER'}
 
-    def execute(self, context):
+    def execute(self, _context):
         image_name = ProjectEdit._proj_hack[0]  # TODO, deal with this nicer
 
         try:
index 3ce1aba..395423f 100644 (file)
@@ -25,7 +25,7 @@ class MASK_MT_add(Menu):
     bl_idname = "MASK_MT_add"
     bl_label = "Add"
 
-    def draw(self, context):
+    def draw(self, _context):
         layout = self.layout
 
         layout.operator_context = 'INVOKE_REGION_WIN'
index c05ee01..f68b591 100644 (file)
@@ -103,7 +103,7 @@ class SelectPattern(Operator):
         wm = context.window_manager
         return wm.invoke_props_popup(self, event)
 
-    def draw(self, context):
+    def draw(self, _context):
         layout = self.layout
 
         layout.prop(self, "pattern")
@@ -610,7 +610,6 @@ class MakeDupliFace(Operator):
             rot = matrix.to_3x3()  # also contains scale
 
             return [(rot @ b) + trans for b in base_tri]
-        scene = context.scene
         linked = defaultdict(list)
         for obj in context.selected_objects:
             if obj.type == 'MESH':
@@ -895,7 +894,7 @@ class LoadImageAsEmpty:
     def poll(cls, context):
         return context.mode == 'OBJECT'
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         context.window_manager.fileselect_add(self)
         return {'RUNNING_MODAL'}
 
index 798dd0b..87e8801 100644 (file)
@@ -304,7 +304,7 @@ class QuickExplode(ObjectModeOperator, Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         self.frame_start = context.scene.frame_current
         self.frame_end = self.frame_start + self.frame_duration
         return self.execute(context)
index bfac9cc..a9a6819 100644 (file)
 
 # <pep8-80 compliant>
 
-import bpy
 from bpy.types import Operator
 from mathutils import Vector
 
 
 def randomize_selected(context, seed, delta,
-                       loc, rot, scale, scale_even, scale_min):
+                       loc, rot, scale, scale_even, _scale_min):
 
     import random
     from random import uniform
index c7f516f..8ca0893 100644 (file)
@@ -209,10 +209,10 @@ class AddPresetBase:
 
         return {'FINISHED'}
 
-    def check(self, context):
+    def check(self, _context):
         self.name = self.as_filename(self.name.strip())
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         if not (self.remove_active or self.remove_name):
             wm = context.window_manager
             return wm.invoke_props_dialog(self)
@@ -535,7 +535,7 @@ class AddPresetKeyconfig(AddPresetBase, Operator):
     preset_menu = "USERPREF_MT_keyconfigs"
     preset_subdir = "keyconfig"
 
-    def add(self, context, filepath):
+    def add(self, _context, filepath):
         bpy.ops.preferences.keyconfig_export(filepath=filepath)
         bpy.utils.keyconfig_set(filepath)
 
index f897435..f16f97a 100644 (file)
@@ -201,7 +201,7 @@ class BakeToKeyframes(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         scene = context.scene
         self.frame_start = scene.frame_start
         self.frame_end = scene.frame_end
index bd27ce9..910fe4d 100644 (file)
@@ -58,7 +58,7 @@ class PREFERENCES_OT_keyconfig_activate(Operator):
         subtype='FILE_PATH',
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         if bpy.utils.keyconfig_set(self.filepath, report=self.report):
             return {'FINISHED'}
         else:
@@ -87,7 +87,7 @@ class PREFERENCES_OT_copy_prev(Operator):
         return bpy.utils.resource_path('USER')
 
     @classmethod
-    def poll(cls, context):
+    def poll(cls, _context):
         import os
 
         old = cls._old_path()
@@ -109,7 +109,7 @@ class PREFERENCES_OT_copy_prev(Operator):
         new_userpref = os.path.join(new, "config", "userpref.blend")
         return os.path.isfile(old_userpref) and not os.path.isfile(new_userpref)
 
-    def execute(self, context):
+    def execute(self, _context):
         import shutil
 
         shutil.copytree(self._old_path(), self._new_path(), symlinks=True)
@@ -173,7 +173,7 @@ class PREFERENCES_OT_keyconfig_import(Operator):
         default=True,
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import os
         from os.path import basename
         import shutil
@@ -202,7 +202,7 @@ class PREFERENCES_OT_keyconfig_import(Operator):
         else:
             return {'CANCELLED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
@@ -260,7 +260,7 @@ class PREFERENCES_OT_keyconfig_export(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
@@ -388,7 +388,7 @@ class PREFERENCES_OT_addon_enable(Operator):
         description="Module name of the add-on to enable",
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import addon_utils
 
         err_str = ""
@@ -434,7 +434,7 @@ class PREFERENCES_OT_addon_disable(Operator):
         description="Module name of the add-on to disable",
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import addon_utils
 
         err_str = ""
@@ -476,7 +476,7 @@ class PREFERENCES_OT_theme_install(Operator):
         options={'HIDDEN'},
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import os
         import shutil
         import traceback
@@ -509,7 +509,7 @@ class PREFERENCES_OT_theme_install(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
@@ -520,7 +520,7 @@ class PREFERENCES_OT_addon_refresh(Operator):
     bl_idname = "preferences.addon_refresh"
     bl_label = "Refresh"
 
-    def execute(self, context):
+    def execute(self, _context):
         import addon_utils
 
         addon_utils.modules_refresh()
@@ -680,7 +680,7 @@ class PREFERENCES_OT_addon_install(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
@@ -735,12 +735,12 @@ class PREFERENCES_OT_addon_remove(Operator):
         return {'FINISHED'}
 
     # lame confirmation check
-    def draw(self, context):
+    def draw(self, _context):
         self.layout.label(text="Remove Add-on: %r?" % self.module)
         path, _isdir = PREFERENCES_OT_addon_remove.path_from_addon(self.module)
         self.layout.label(text="Path: %r" % path)
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         return wm.invoke_props_dialog(self, width=600)
 
@@ -756,7 +756,7 @@ class PREFERENCES_OT_addon_expand(Operator):
         description="Module name of the add-on to expand",
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import addon_utils
 
         module_name = self.module
@@ -825,7 +825,7 @@ class PREFERENCES_OT_app_template_install(Operator):
         options={'HIDDEN'},
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import traceback
         import zipfile
         import os
@@ -893,7 +893,7 @@ class PREFERENCES_OT_app_template_install(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
@@ -955,7 +955,7 @@ class PREFERENCES_OT_studiolight_install(Operator):
         self.report({'INFO'}, msg)
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
 
         if self.type == 'STUDIO':
@@ -1009,14 +1009,14 @@ class PREFERENCES_OT_studiolight_new(Operator):
         self.report({'INFO'}, msg)
         return {'FINISHED'}
 
-    def draw(self, context):
+    def draw(self, _context):
         layout = self.layout
         if self.ask_overide:
             layout.label(text="Warning, file already exists. Overwrite existing file?")
         else:
             layout.prop(self, "filename")
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         return wm.invoke_props_dialog(self, width=600)
 
index cf98722..d7a8630 100644 (file)
@@ -31,7 +31,7 @@ STATUS_ERR_NOT_SELECTED = (1 << 2)
 STATUS_ERR_NOT_QUAD = (1 << 3)
 
 
-def extend(obj, operator, EXTEND_MODE):
+def extend(obj, EXTEND_MODE):
     import bmesh
     me = obj.data
 
@@ -119,7 +119,7 @@ def extend(obj, operator, EXTEND_MODE):
         l_b_inner[:] = l_a_inner
         l_b_outer[:] = l_a_inner + ((l_a_inner - l_a_outer) * fac)
 
-    def apply_uv(f_prev, l_prev, f_next):
+    def apply_uv(_f_prev, l_prev, _f_next):
         l_a = [None, None, None, None]
         l_b = [None, None, None, None]
 
@@ -232,7 +232,7 @@ def main(context, operator):
     for ob in ob_list:
         num_meshes += 1
 
-        ret = extend(ob, operator, operator.properties.mode)
+        ret = extend(ob, operator.properties.mode)
         if ret != STATUS_OK:
             num_errors += 1
             status |= ret
@@ -272,7 +272,7 @@ class FollowActiveQuads(Operator):
         main(context, self)
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         return wm.invoke_props_dialog(self)
 
index 402fe7d..b5cb502 100644 (file)
@@ -686,7 +686,7 @@ class LightMapPack(Operator):
 
         return unwrap(self, context, **kwargs)
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         return wm.invoke_props_dialog(self)
 
index 528513a..321c4d7 100644 (file)
@@ -1033,7 +1033,7 @@ class SmartProject(Operator):
              )
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         wm = context.window_manager
         return wm.invoke_props_dialog(self)
 
index fdd844c..1f982c3 100644 (file)
@@ -125,7 +125,6 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
     return {'FINISHED'}
 
 
-import bpy
 from bpy.types import Operator
 from bpy.props import FloatProperty, IntProperty, BoolProperty
 from math import pi
index 537ad46..e1d2dda 100644 (file)
@@ -20,7 +20,6 @@
 
 import bpy
 from bpy.types import Operator
-from bpy.props import BoolProperty
 
 
 class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
@@ -60,7 +59,7 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
         # and cause this one not to be freed. [#24671]
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         return self.execute(context)
 
 
@@ -118,7 +117,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
     def execute(self, context):
         return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, False)
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         return self.execute(context)
 
 
@@ -135,7 +134,7 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
     def execute(self, context):
         return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True)
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         return self.execute(context)
 
 
index 5e63342..9a139c8 100644 (file)
@@ -824,7 +824,7 @@ class WM_OT_url_open(Operator):
         description="URL to open",
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import webbrowser
         webbrowser.open(self.url)
         return {'FINISHED'}
@@ -841,7 +841,7 @@ class WM_OT_path_open(Operator):
         options={'SKIP_SAVE'},
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import sys
         import os
         import subprocess
@@ -978,7 +978,7 @@ class WM_OT_doc_view_manual(Operator):
                 url = prefix + rna_ref
                 return url
 
-    def execute(self, context):
+    def execute(self, _context):
         rna_id = _wm_doc_get_id(self.doc_id, do_url=False)
         if rna_id is None:
             return {'PASS_THROUGH'}
@@ -1011,7 +1011,7 @@ class WM_OT_doc_view(Operator):
     else:
         _prefix = ("https://docs.blender.org/api/master")
 
-    def execute(self, context):
+    def execute(self, _context):
         url = _wm_doc_get_id(self.doc_id, do_url=True, url_prefix=self._prefix)
         if url is None:
             return {'PASS_THROUGH'}
@@ -1213,7 +1213,7 @@ class WM_OT_properties_edit(Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         from rna_prop_ui import rna_idprop_ui_prop_get
 
         data_path = self.data_path
@@ -1261,7 +1261,7 @@ class WM_OT_properties_edit(Operator):
         wm = context.window_manager
         return wm.invoke_props_dialog(self)
 
-    def check(self, context):
+    def check(self, _context):
         cmp_props = self._cmp_props_get()
         changed = False
         if self._cmp_props != cmp_props:
@@ -1289,7 +1289,7 @@ class WM_OT_properties_edit(Operator):
 
         return changed
 
-    def draw(self, context):
+    def draw(self, _context):
         layout = self.layout
         layout.prop(self, "property")
         layout.prop(self, "value")
@@ -1399,12 +1399,12 @@ class WM_OT_sysinfo(Operator):
         options={'SKIP_SAVE'},
     )
 
-    def execute(self, context):
+    def execute(self, _context):
         import sys_info
         sys_info.write_sysinfo(self.filepath)
         return {'FINISHED'}
 
-    def invoke(self, context, event):
+    def invoke(self, _context, _event):
         import os
 
         if not self.filepath:
@@ -1421,7 +1421,7 @@ class WM_OT_operator_cheat_sheet(Operator):
     bl_idname = "wm.operator_cheat_sheet"
     bl_label = "Operator Cheat Sheet"
 
-    def execute(self, context):
+    def execute(self, _context):
         op_strings = []
         tot = 0
         for op_module_name in dir(bpy.ops):
@@ -1739,11 +1739,11 @@ class WM_OT_drop_blend_file(Operator):
 
     filepath: StringProperty()
 
-    def invoke(self, context, event):
+    def invoke(self, context, _event):
         context.window_manager.popup_menu(self.draw_menu, title=bpy.path.basename(self.filepath), icon='QUESTION')
         return {'FINISHED'}
 
-    def draw_menu(self, menu, context):
+    def draw_menu(self, menu, _context):
         layout = menu.layout
 
         col = layout.column()