From 0a4fdcbb5fe3b33a276d2ab54a1e68db0fe24fd4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Mar 2022 11:03:36 +1100 Subject: [PATCH] Cleanup: unused Python variables & imports --- doc/manpage/blender.1.py | 1 - intern/cycles/blender/addon/properties.py | 3 +-- intern/cycles/blender/addon/version_update.py | 1 - release/scripts/modules/bpy_extras/io_utils.py | 1 - release/scripts/modules/rna_xml.py | 12 ++++++------ .../keymap_data/industry_compatible_data.py | 2 +- .../scripts/startup/bl_ui/space_filebrowser.py | 3 --- release/scripts/startup/bl_ui/space_image.py | 15 +++++---------- release/scripts/startup/bl_ui/space_outliner.py | 2 -- release/scripts/startup/bl_ui/space_sequencer.py | 8 +++----- .../startup/bl_ui/space_toolsystem_toolbar.py | 3 --- release/scripts/startup/bl_ui/space_topbar.py | 1 - tests/python/bl_mesh_validate.py | 1 - 13 files changed, 16 insertions(+), 37 deletions(-) diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py index 325b4c2653b..640b00b0c00 100755 --- a/doc/manpage/blender.1.py +++ b/doc/manpage/blender.1.py @@ -16,7 +16,6 @@ and is where to write the generated man page. import argparse import os import subprocess -import sys import time from typing import ( diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index e3e5734c6b6..8896f620b9f 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -216,7 +216,6 @@ enum_direct_light_sampling_type = ( ) def update_render_passes(self, context): - scene = context.scene view_layer = context.view_layer view_layer.update_render_passes() @@ -1353,7 +1352,7 @@ class CyclesPreferences(bpy.types.AddonPreferences): items=CyclesPreferences.get_device_types, ) - devices: bpy.props.CollectionProperty(type=CyclesDeviceSettings) + devices: CollectionProperty(type=CyclesDeviceSettings) peer_memory: BoolProperty( name="Distribute memory across devices", diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index e844ea8407a..aade864e4c7 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -5,7 +5,6 @@ from __future__ import annotations import bpy -import math from bpy.app.handlers import persistent diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 37fc8aa4412..3a73603ba85 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -344,7 +344,6 @@ def create_derived_objects(depsgraph, objects): :rtype: dict """ result = {} - has_instancer = False for ob in objects: ob_parent = ob.parent if ob_parent and ob_parent.instance_type in {'VERTS', 'FACES'}: diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 530542e6089..5a76c7878b8 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -250,19 +250,19 @@ def xml2rna( value_xml = xml_node.attributes[attr].value subvalue_type = type(subvalue) - tp_name = 'UNKNOWN' + # tp_name = 'UNKNOWN' if subvalue_type == float: value_xml_coerce = float(value_xml) - tp_name = 'FLOAT' + # tp_name = 'FLOAT' elif subvalue_type == int: value_xml_coerce = int(value_xml) - tp_name = 'INT' + # tp_name = 'INT' elif subvalue_type == bool: value_xml_coerce = {'TRUE': True, 'FALSE': False}[value_xml] - tp_name = 'BOOL' + # tp_name = 'BOOL' elif subvalue_type == str: value_xml_coerce = value_xml - tp_name = 'STR' + # tp_name = 'STR' elif hasattr(subvalue, "__len__"): if value_xml.startswith("#"): # read hexadecimal value as float array @@ -280,7 +280,7 @@ def xml2rna( except ValueError: # bool vector property value_xml_coerce = [{'TRUE': True, 'FALSE': False}[v] for v in value_xml_split] del value_xml_split - tp_name = 'ARRAY' + # tp_name = 'ARRAY' # print(" %s.%s (%s) --- %s" % (type(value).__name__, attr, tp_name, subvalue_type)) try: diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index 8c303bc3f69..3469dbdc175 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -4173,7 +4173,7 @@ def keymap_transform_tool_mmb(keymap): r".*\bSelect Lasso$|" r".*\bTweak$)", ) - for km_name, km_args, km_content in keymap: + for km_name, _km_args, km_content in keymap: if re_fallback_tool.match(km_name): km_items = km_content["items"] km_items_new = [] diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index e8969c0aa22..53d2cdc8339 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -694,9 +694,6 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel): layout.label(text="No active asset", icon='INFO') return - asset_library_ref = context.asset_library_ref - asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library_ref) - prefs = context.preferences show_asset_debug_info = prefs.view.show_developer_ui and prefs.experimental.show_asset_debug_info diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 0aac224bc68..65d624a253d 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -759,7 +759,6 @@ class IMAGE_HT_header(Header): ima = sima.image iuser = sima.image_user tool_settings = context.tool_settings - show_region_tool_header = sima.show_region_tool_header show_render = sima.show_render show_uvedit = sima.show_uvedit @@ -772,8 +771,6 @@ class IMAGE_HT_header(Header): # UV editing. if show_uvedit: - uvedit = sima.uv_editor - layout.prop(tool_settings, "use_uv_select_sync", text="") if tool_settings.use_uv_select_sync: @@ -781,15 +778,15 @@ class IMAGE_HT_header(Header): else: row = layout.row(align=True) uv_select_mode = tool_settings.uv_select_mode[:] - row.operator("uv.select_mode", text="", icon='UV_VERTEXSEL', + row.operator("uv.select_mode", text="", icon='UV_VERTEXSEL', depress=(uv_select_mode == 'VERTEX')).type = 'VERTEX' - row.operator("uv.select_mode", text="", icon='UV_EDGESEL', + row.operator("uv.select_mode", text="", icon='UV_EDGESEL', depress=(uv_select_mode == 'EDGE')).type = 'EDGE' - row.operator("uv.select_mode", text="", icon='UV_FACESEL', + row.operator("uv.select_mode", text="", icon='UV_FACESEL', depress=(uv_select_mode == 'FACE')).type = 'FACE' - row.operator("uv.select_mode", text="", icon='UV_ISLANDSEL', + row.operator("uv.select_mode", text="", icon='UV_ISLANDSEL', depress=(uv_select_mode == 'ISLAND')).type = 'ISLAND' - + layout.prop(tool_settings, "uv_sticky_select_mode", icon_only=True) IMAGE_MT_editor_menus.draw_collapsible(context, layout) @@ -817,8 +814,6 @@ class IMAGE_HT_header(Header): sub.popover(panel="IMAGE_PT_overlay", text="") if show_uvedit: - uvedit = sima.uv_editor - mesh = context.edit_object.data layout.prop_search(mesh.uv_layers, "active", mesh, "uv_layers", text="") diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index a2fdea91a8e..9d3f20ce4a4 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -311,8 +311,6 @@ class OUTLINER_MT_asset(Menu): def draw(self, context): layout = self.layout - space = context.space_data - layout.operator("asset.mark") layout.operator("asset.clear", text="Clear Asset").set_fake_user = False layout.operator("asset.clear", text="Clear Asset (Set Fake User)").set_fake_user = True diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 76a69e878b0..96ac62fb502 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -130,7 +130,7 @@ class SEQUENCER_HT_tool_header(Header): bl_region_type = 'TOOL_HEADER' def draw(self, context): - layout = self.layout + # layout = self.layout self.draw_tool_settings(context) @@ -241,7 +241,6 @@ class SEQUENCER_PT_gizmo_display(Panel): def draw(self, context): layout = self.layout - scene = context.scene st = context.space_data col = layout.column() @@ -555,7 +554,7 @@ class SEQUENCER_MT_select(Menu): def draw(self, context): layout = self.layout st = context.space_data - has_sequencer, has_preview = _space_view_types(st) + has_sequencer, _has_preview = _space_view_types(st) layout.operator("sequencer.select_all", text="All").action = 'SELECT' layout.operator("sequencer.select_all", text="None").action = 'DESELECT' @@ -891,7 +890,7 @@ class SEQUENCER_MT_strip(Menu): def draw(self, context): layout = self.layout st = context.space_data - has_sequencer, has_preview = _space_view_types(st) + has_sequencer, _has_preview = _space_view_types(st) layout.menu("SEQUENCER_MT_strip_transform") layout.separator() @@ -1134,7 +1133,6 @@ class SEQUENCER_MT_pivot_pie(Menu): layout = self.layout pie = layout.menu_pie() - tool_settings = context.tool_settings sequencer_tool_settings = context.tool_settings.sequencer_tool_settings pie.prop_enum(sequencer_tool_settings, "pivot_point", value='CENTER') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index f4aa4c50d76..aec3ec63a0c 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1065,11 +1065,8 @@ class _defs_edit_mesh: show_extra = False props = tool.operator_properties("mesh.knife_tool") if not extra: - row = layout.row() layout.prop(props, "use_occlude_geometry") - row = layout.row() layout.prop(props, "only_selected") - row = layout.row() layout.prop(props, "xray") region_is_header = bpy.context.region.type == 'TOOL_HEADER' if region_is_header: diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 3b6bdd01efa..3355b30dd61 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -796,7 +796,6 @@ class TOPBAR_PT_name(Panel): return row mode = context.mode - scene = context.scene space = context.space_data space_type = None if (space is None) else space.type found = False diff --git a/tests/python/bl_mesh_validate.py b/tests/python/bl_mesh_validate.py index 38d84c42a55..9a9384ce777 100644 --- a/tests/python/bl_mesh_validate.py +++ b/tests/python/bl_mesh_validate.py @@ -7,7 +7,6 @@ import bpy -import sys import random