From 432bfbf7a3b74943b1c251c12bd76616da23991f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Jul 2021 12:05:27 +1000 Subject: [PATCH] Cleanup: pep8 --- doc/python_api/examples/bpy.app.handlers.2.py | 1 + doc/python_api/examples/bpy.app.timers.5.py | 2 ++ doc/python_api/examples/bpy.msgbus.1.py | 2 ++ doc/python_api/examples/bpy.types.Depsgraph.7.py | 2 +- doc/python_api/examples/gpu.6.py | 1 + release/scripts/modules/bl_i18n_utils/utils.py | 1 - release/scripts/modules/bl_i18n_utils/utils_cli.py | 1 + .../modules/bl_keymap_utils/keymap_from_toolbar.py | 1 - .../modules/bl_previews_utils/bl_previews_render.py | 1 + release/scripts/modules/bl_rna_utils/data_path.py | 1 + release/scripts/modules/bpy/utils/__init__.py | 1 + release/scripts/modules/bpy_extras/asset_utils.py | 3 +++ .../scripts/modules/bpy_extras/node_shader_utils.py | 7 +++++-- release/scripts/modules/console/complete_calltip.py | 2 +- release/scripts/startup/bl_operators/spreadsheet.py | 1 + release/scripts/startup/bl_operators/wm.py | 2 +- .../scripts/startup/bl_ui/properties_collection.py | 4 ++-- .../scripts/startup/bl_ui/properties_data_gpencil.py | 8 ++++---- .../startup/bl_ui/properties_grease_pencil_common.py | 1 + release/scripts/startup/bl_ui/space_clip.py | 10 +++++++--- release/scripts/startup/bl_ui/space_dopesheet.py | 10 +++++----- release/scripts/startup/bl_ui/space_image.py | 1 + release/scripts/startup/bl_ui/space_outliner.py | 1 - release/scripts/startup/bl_ui/space_sequencer.py | 12 ++++++------ release/scripts/startup/bl_ui/space_spreadsheet.py | 3 ++- release/scripts/startup/bl_ui/space_userpref.py | 1 - release/scripts/startup/bl_ui/space_view3d.py | 2 +- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 6 +++--- release/scripts/startup/keyingsets_builtins.py | 1 + release/scripts/templates_py/image_processing.py | 4 ++-- release/scripts/templates_py/operator_mesh_add.py | 1 + tests/performance/api/__init__.py | 1 - tests/performance/api/config.py | 4 ++++ tests/performance/api/device.py | 5 ++++- tests/performance/api/environment.py | 1 + tests/performance/api/graph.py | 2 +- tests/performance/api/test.py | 2 ++ tests/performance/tests/__init__.py | 1 - tests/performance/tests/animation.py | 3 +++ tests/performance/tests/blend_load.py | 3 +++ tests/performance/tests/cycles.py | 3 +++ tests/python/bl_animation_fcurves.py | 1 + tests/python/bl_blendfile_library_overrides.py | 8 ++++---- tests/python/bl_pyapi_idprop.py | 1 + tests/python/compositor_render_tests.py | 1 + tests/python/cycles_render_tests.py | 1 + tests/python/modules/mesh_test.py | 2 +- tests/python/operators.py | 2 +- 48 files changed, 89 insertions(+), 46 deletions(-) diff --git a/doc/python_api/examples/bpy.app.handlers.2.py b/doc/python_api/examples/bpy.app.handlers.2.py index aaaedeabecb..d514fa3fa4b 100644 --- a/doc/python_api/examples/bpy.app.handlers.2.py +++ b/doc/python_api/examples/bpy.app.handlers.2.py @@ -12,6 +12,7 @@ such cases, lock the interface (Render → Lock Interface or Below is an example of a mesh that is altered from a handler: """ + def frame_change_pre(scene): # A triangle that shifts in the z direction zshift = scene.frame_current * 0.1 diff --git a/doc/python_api/examples/bpy.app.timers.5.py b/doc/python_api/examples/bpy.app.timers.5.py index 821a047d7c7..dda5ea12e73 100644 --- a/doc/python_api/examples/bpy.app.timers.5.py +++ b/doc/python_api/examples/bpy.app.timers.5.py @@ -16,10 +16,12 @@ execution_queue = queue.Queue() def run_in_main_thread(function): execution_queue.put(function) + def execute_queued_functions(): while not execution_queue.empty(): function = execution_queue.get() function() return 1.0 + bpy.app.timers.register(execute_queued_functions) diff --git a/doc/python_api/examples/bpy.msgbus.1.py b/doc/python_api/examples/bpy.msgbus.1.py index 21198471ffa..8164272d521 100644 --- a/doc/python_api/examples/bpy.msgbus.1.py +++ b/doc/python_api/examples/bpy.msgbus.1.py @@ -31,11 +31,13 @@ owner = object() subscribe_to = bpy.context.object.location + def msgbus_callback(*args): # This will print: # Something changed! (1, 2, 3) print("Something changed!", args) + bpy.msgbus.subscribe_rna( key=subscribe_to, owner=owner, diff --git a/doc/python_api/examples/bpy.types.Depsgraph.7.py b/doc/python_api/examples/bpy.types.Depsgraph.7.py index 11982730fc9..afea8dfd618 100644 --- a/doc/python_api/examples/bpy.types.Depsgraph.7.py +++ b/doc/python_api/examples/bpy.types.Depsgraph.7.py @@ -44,7 +44,7 @@ class OBJECT_OT_object_to_curve(bpy.types.Operator): # Remove temporary curve. obj.to_curve_clear() # Invoke to_curve() with applying modifiers. - curve_with_modifiers = obj.to_curve(depsgraph, apply_modifiers = True) + curve_with_modifiers = obj.to_curve(depsgraph, apply_modifiers=True) self.report({'INFO'}, f"{len(curve_with_modifiers.splines)} splines in new curve with modifiers.") # Remove temporary curve. obj.to_curve_clear() diff --git a/doc/python_api/examples/gpu.6.py b/doc/python_api/examples/gpu.6.py index 334a606055a..be164a03028 100644 --- a/doc/python_api/examples/gpu.6.py +++ b/doc/python_api/examples/gpu.6.py @@ -21,6 +21,7 @@ batch = batch_for_shader( }, ) + def draw(): shader.bind() shader.uniform_sampler("image", texture) diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index f63b6990cdd..fda93682dc5 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -781,7 +781,6 @@ class I18nMessages: print("Could not import bpy, find_best_messages_matches must be run from whithin Blender.") return - # Build helper mappings. # Note it's user responsibility to know when to invalidate (and hence force rebuild) this cache! if self._reverse_cache is None: diff --git a/release/scripts/modules/bl_i18n_utils/utils_cli.py b/release/scripts/modules/bl_i18n_utils/utils_cli.py index d3750d5e9a4..e18491fa042 100644 --- a/release/scripts/modules/bl_i18n_utils/utils_cli.py +++ b/release/scripts/modules/bl_i18n_utils/utils_cli.py @@ -140,6 +140,7 @@ def main(): args.func(args=args, settings=settings) + if __name__ == "__main__": print("\n\n *** Running {} *** \n".format(__file__)) main() diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py index aff1108568b..26f38cf09fc 100644 --- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py +++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py @@ -449,6 +449,5 @@ def generate(context, space_type, *, use_fallback_keys=True, use_reset=True): ) kmi.properties.skip_depressed = True - wm.keyconfigs.update() return keymap diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py index 51ea53c0eba..17577a9a9f2 100644 --- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py +++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py @@ -37,6 +37,7 @@ OBJECT_TYPES_RENDER = {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'} def ids_nolib(bids): return (bid for bid in bids if not bid.library) + def ids_nolib_with_preview(bids): return (bid for bid in bids if (not bid.library and bid.preview)) diff --git a/release/scripts/modules/bl_rna_utils/data_path.py b/release/scripts/modules/bl_rna_utils/data_path.py index 42942b7a295..439dfcae12a 100644 --- a/release/scripts/modules/bl_rna_utils/data_path.py +++ b/release/scripts/modules/bl_rna_utils/data_path.py @@ -23,6 +23,7 @@ __all__ = ( "decompose_data_path", ) + class _TokenizeDataPath: """ Class to split up tokens of a data-path. diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index e6c7bca3e3c..58b20d9e3c8 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -155,6 +155,7 @@ def _test_import(module_name, loaded_modules): # This supports the case of loading a new preferences file which may reset scripts path. _sys_path_ensure_paths = set() + def _sys_path_ensure_prepend(path): if path not in _sys.path: _sys.path.insert(0, path) diff --git a/release/scripts/modules/bpy_extras/asset_utils.py b/release/scripts/modules/bpy_extras/asset_utils.py index 1656c21a137..e41eeeed4fa 100644 --- a/release/scripts/modules/bpy_extras/asset_utils.py +++ b/release/scripts/modules/bpy_extras/asset_utils.py @@ -31,6 +31,7 @@ __all__ = ( "SpaceAssetInfo", ) + class SpaceAssetInfo: @classmethod def is_asset_browser(cls, space_data: bpy.types.Space): @@ -46,6 +47,7 @@ class SpaceAssetInfo: active_file = context.active_file return active_file.asset_data if active_file else None + class AssetBrowserPanel: bl_space_type = 'FILE_BROWSER' @@ -53,6 +55,7 @@ class AssetBrowserPanel: def poll(cls, context): return SpaceAssetInfo.is_asset_browser_poll(context) + class AssetMetaDataPanel: bl_space_type = 'FILE_BROWSER' bl_region_type = 'TOOL_PROPS' diff --git a/release/scripts/modules/bpy_extras/node_shader_utils.py b/release/scripts/modules/bpy_extras/node_shader_utils.py index 54124fd4ca6..e37c1a17152 100644 --- a/release/scripts/modules/bpy_extras/node_shader_utils.py +++ b/release/scripts/modules/bpy_extras/node_shader_utils.py @@ -681,7 +681,10 @@ class ShaderImageTextureWrapper(): tree = self.owner_shader.material.node_tree node_image = tree.nodes.new(type='ShaderNodeTexImage') - self.owner_shader._grid_to_location(-1, 0 + self.grid_row_diff, dst_node=node_image, ref_node=self.node_dst) + self.owner_shader._grid_to_location( + -1, 0 + self.grid_row_diff, + dst_node=node_image, ref_node=self.node_dst, + ) tree.links.new(node_image.outputs["Alpha" if self.use_alpha else "Color"], self.socket_dst) if self.use_alpha: @@ -778,7 +781,7 @@ class ShaderImageTextureWrapper(): socket_dst = self.node_image.inputs["Vector"] # If not already existing, we need to create texcoords -> mapping link (from UV). socket_src = (socket_dst.links[0].from_socket if socket_dst.is_linked - else self.owner_shader.node_texcoords.outputs['UV']) + else self.owner_shader.node_texcoords.outputs['UV']) tree = self.owner_shader.material.node_tree node_mapping = tree.nodes.new(type='ShaderNodeMapping') diff --git a/release/scripts/modules/console/complete_calltip.py b/release/scripts/modules/console/complete_calltip.py index 706af67905b..60daa1d2045 100644 --- a/release/scripts/modules/console/complete_calltip.py +++ b/release/scripts/modules/console/complete_calltip.py @@ -41,7 +41,7 @@ RE_DEF_COMPLETE = re.compile( # allow empty string '''|)''' # allow opening bracket(s) - '''(?:\(|\s)*)$''') + r'''(?:\(|\s)*)$''') def reduce_newlines(text): diff --git a/release/scripts/startup/bl_operators/spreadsheet.py b/release/scripts/startup/bl_operators/spreadsheet.py index 1907a69a3d3..b5098d63dac 100644 --- a/release/scripts/startup/bl_operators/spreadsheet.py +++ b/release/scripts/startup/bl_operators/spreadsheet.py @@ -20,6 +20,7 @@ from __future__ import annotations from bpy.types import Operator + class SPREADSHEET_OT_toggle_pin(Operator): '''Turn on or off pinning''' bl_idname = "spreadsheet.toggle_pin" diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 2cc7b828c11..6a3830ad1e4 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -135,7 +135,7 @@ def context_path_decompose(data_path): if base_path: assert(base_path.startswith(".")) - base_path= base_path[1:] + base_path = base_path[1:] if prop_attr: assert(prop_attr.startswith(".")) prop_attr = prop_attr[1:] diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py index 27de80bb88d..b51d7157c06 100644 --- a/release/scripts/startup/bl_ui/properties_collection.py +++ b/release/scripts/startup/bl_ui/properties_collection.py @@ -35,7 +35,7 @@ def lineart_make_line_type_entry(col, line_type, text_disp, expand, search_from) if line_type.use and expand: col.prop_search(line_type, "layer", search_from, "layers", icon='GREASEPENCIL') - col.prop_search(line_type, "material", search_from, + col.prop_search(line_type, "material", search_from, "materials", icon='SHADING_TEXTURE') @@ -90,7 +90,7 @@ class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel): row = layout.row(align=True, heading="Masks") row.active = collection.lineart_use_intersection_mask - for i in range(0,8): + for i in range(8): row.prop(collection, "lineart_intersection_mask", index=i, text=str(i), toggle=True) diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py index e71ea2f31a4..b273eee4e19 100644 --- a/release/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py @@ -93,8 +93,8 @@ class GPENCIL_MT_layer_context_menu(Menu): gpd = ob.data gpl = gpd.layers.active - layout.operator("gpencil.layer_duplicate", text="Duplicate", icon='DUPLICATE').mode='ALL' - layout.operator("gpencil.layer_duplicate", text="Duplicate Empty Keyframes").mode='EMPTY' + layout.operator("gpencil.layer_duplicate", text="Duplicate", icon='DUPLICATE').mode = 'ALL' + layout.operator("gpencil.layer_duplicate", text="Duplicate Empty Keyframes").mode = 'EMPTY' layout.separator() @@ -113,8 +113,8 @@ class GPENCIL_MT_layer_context_menu(Menu): layout.operator("gpencil.layer_merge", icon='SORT_ASC', text="Merge Down") layout.separator() - layout.operator("gpencil.layer_duplicate_object", text="Copy Layer to Selected").only_active=True - layout.operator("gpencil.layer_duplicate_object", text="Copy All Layers to Selected").only_active=False + layout.operator("gpencil.layer_duplicate_object", text="Copy Layer to Selected").only_active = True + layout.operator("gpencil.layer_duplicate_object", text="Copy All Layers to Selected").only_active = False class DATA_PT_gpencil_layers(DataButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 0da0716e850..de743033036 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -847,6 +847,7 @@ class GreasePencilLayerRelationsPanel: col.enabled = bool(gpl.viewlayer_render) col.prop(gpl, "use_viewlayer_masks") + class GreasePencilLayerDisplayPanel: def draw(self, context): diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 96920af1c7e..926be1ff820 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -1477,9 +1477,13 @@ class CLIP_MT_track(Menu): layout.separator() - layout.operator("clip.solve_camera", - text="Solve Camera Motion" if tracking_object.is_camera - else "Solve Object Motion") + layout.operator( + "clip.solve_camera", + text=( + "Solve Camera Motion" if tracking_object.is_camera else + "Solve Object Motion" + ), + ) layout.separator() diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index ffb7b9e5c20..84d1c36c53d 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -609,9 +609,9 @@ class DOPESHEET_MT_context_menu(Menu): layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type") if st.mode != 'GPENCIL': - layout.operator_menu_enum("action.handle_type", "type", text="Handle Type") - layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode") - layout.operator_menu_enum("action.easing_type", "type", text="Easing Mode") + layout.operator_menu_enum("action.handle_type", "type", text="Handle Type") + layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode") + layout.operator_menu_enum("action.easing_type", "type", text="Easing Mode") layout.separator() @@ -625,8 +625,8 @@ class DOPESHEET_MT_context_menu(Menu): layout.operator("action.delete") if st.mode == 'GPENCIL': - layout.operator("gpencil.interpolate_reverse") - layout.operator("gpencil.frame_clean_duplicate", text="Delete Duplicate Frames") + layout.operator("gpencil.interpolate_reverse") + layout.operator("gpencil.frame_clean_duplicate", text="Delete Duplicate Frames") layout.separator() diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 31a4aa5da48..0fceb864ac2 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -260,6 +260,7 @@ class IMAGE_MT_image_flip(Menu): layout.operator("image.flip", text="Horizontally").use_flip_x = True layout.operator("image.flip", text="Vertically").use_flip_y = True + class IMAGE_MT_image_invert(Menu): bl_label = "Invert" diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 7a694108e14..ba91b6e8d50 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -442,7 +442,6 @@ class OUTLINER_PT_filter(Panel): row.prop(space, "use_filter_lib_override_system", text="System Overrides") - classes = ( OUTLINER_HT_header, OUTLINER_MT_editor_menus, diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 99384ac713d..5e92e088b36 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -400,7 +400,7 @@ class SEQUENCER_MT_view(Menu): layout.menu("SEQUENCER_MT_proxy") layout.operator_context = 'INVOKE_DEFAULT' - + layout.separator() layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("sequencer.refresh_all", icon='FILE_REFRESH', text="Refresh All") @@ -467,6 +467,7 @@ class SEQUENCER_MT_select_handle(Menu): layout.operator("sequencer.select_handles", text="Left Neighbor").side = 'LEFT_NEIGHBOR' layout.operator("sequencer.select_handles", text="Right Neighbor").side = 'RIGHT_NEIGHBOR' + class SEQUENCER_MT_select_channel(Menu): bl_label = "Select Channel" @@ -1415,7 +1416,7 @@ class SEQUENCER_PT_source(SequencerButtonsPanel, Panel): split.label(text="%dx%d" % size, translate=False) else: split.label(text="None") - #FPS + # FPS if elem.orig_fps: split = col.split(factor=0.5, align=False) split.alignment = 'RIGHT' @@ -1424,7 +1425,6 @@ class SEQUENCER_PT_source(SequencerButtonsPanel, Panel): split.label(text="%.2f" % elem.orig_fps, translate=False) - class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel): bl_label = "Scene" bl_category = "Strip" @@ -1857,7 +1857,7 @@ class SEQUENCER_PT_cache_settings(SequencerButtonsPanel, Panel): @classmethod def poll(cls, context): show_developer_ui = context.preferences.view.show_developer_ui - return cls.has_sequencer(context) and context.scene.sequence_editor and show_developer_ui + return cls.has_sequencer(context) and context.scene.sequence_editor and show_developer_ui def draw(self, context): layout = self.layout @@ -2286,12 +2286,12 @@ class SEQUENCER_PT_snapping(Panel): layout.use_property_decorate = False col = layout.column(heading="Snap to", align=True) - col.prop(sequencer_tool_settings, "snap_to_current_frame" ) + col.prop(sequencer_tool_settings, "snap_to_current_frame") col.prop(sequencer_tool_settings, "snap_to_hold_offset") col = layout.column(heading="Ignore", align=True) col.prop(sequencer_tool_settings, "snap_ignore_muted", text="Muted Strips") - col.prop(sequencer_tool_settings, "snap_ignore_sound",text="Sound Strips") + col.prop(sequencer_tool_settings, "snap_ignore_sound", text="Sound Strips") classes = ( diff --git a/release/scripts/startup/bl_ui/space_spreadsheet.py b/release/scripts/startup/bl_ui/space_spreadsheet.py index ad696f23db4..afdbfea5091 100644 --- a/release/scripts/startup/bl_ui/space_spreadsheet.py +++ b/release/scripts/startup/bl_ui/space_spreadsheet.py @@ -58,7 +58,7 @@ class SPREADSHEET_HT_header(bpy.types.Header): layout.label(text="No active viewer node.", icon='INFO') layout.separator_spacer() - + row = layout.row(align=True) sub = row.row(align=True) sub.active = self.selection_filter_available(space) @@ -115,6 +115,7 @@ class SPREADSHEET_HT_header(bpy.types.Header): return False return True + classes = ( SPREADSHEET_HT_header, ) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index f9359a8b4a0..7e6fde1ebaf 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1391,7 +1391,6 @@ class USERPREF_PT_file_paths_asset_libraries(FilePathsPanel, Panel): row.separator() row.label(text="Path") - for i, library in enumerate(paths.asset_libraries): name_col.prop(library, "name", text="") row = path_col.row() diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 80cede9ee5a..1c21d27a117 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3129,7 +3129,6 @@ class VIEW3D_MT_mask(Menu): layout.menu("VIEW3D_MT_random_mask", text="Random Mask") - class VIEW3D_MT_face_sets(Menu): bl_label = "Face Sets" @@ -3259,6 +3258,7 @@ class VIEW3D_MT_random_mask(Menu): op = layout.operator("sculpt.mask_init", text='Per Loose Part') op.mode = 'RANDOM_PER_LOOSE_PART' + class VIEW3D_MT_particle(Menu): bl_label = "Particle" diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index bc385faf378..46fed79332d 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1731,7 +1731,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_paint_falloff(GreasePencilBrushFalloff from bl_ui.space_toolsystem_common import ToolSelectPanelHelper tool = ToolSelectPanelHelper.tool_active_from_context(context) - if tool and tool.idname != 'builtin_brush.Tint': + if tool and tool.idname != 'builtin_brush.Tint': return False gptool = brush.gpencil_tool @@ -2057,7 +2057,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel): from bl_ui.space_toolsystem_common import ToolSelectPanelHelper tool = ToolSelectPanelHelper.tool_active_from_context(context) - if tool and tool.idname in('builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'): + if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}: return False if brush.gpencil_tool == 'TINT': @@ -2118,7 +2118,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel): from bl_ui.space_toolsystem_common import ToolSelectPanelHelper tool = ToolSelectPanelHelper.tool_active_from_context(context) - if tool and tool.idname in('builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'): + if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}: return False if brush.gpencil_tool == 'TINT': diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py index 2fc2d966ea9..ceffeaaff6c 100644 --- a/release/scripts/startup/keyingsets_builtins.py +++ b/release/scripts/startup/keyingsets_builtins.py @@ -383,6 +383,7 @@ class BUILTIN_KSI_Available(KeyingSetInfo): ############################### + class WholeCharacterMixin: # these prefixes should be avoided, as they are not really bones # that animators should be touching (or need to touch) diff --git a/release/scripts/templates_py/image_processing.py b/release/scripts/templates_py/image_processing.py index 2392faf440c..ab14436ad8e 100644 --- a/release/scripts/templates_py/image_processing.py +++ b/release/scripts/templates_py/image_processing.py @@ -20,9 +20,9 @@ input_image.pixels.foreach_get(pixel_data.ravel()) # Do whatever image processing you want using numpy here: # Example 1: Inverse red green and blue channels. -pixel_data[:,:,:3] = 1.0 - pixel_data[:,:,:3] +pixel_data[:, :, :3] = 1.0 - pixel_data[:, :, :3] # Example 2: Change gamma on the red channel. -pixel_data[:,:,0] = np.power(pixel_data[:,:,0], 1.5) +pixel_data[:, :, 0] = np.power(pixel_data[:, :, 0], 1.5) # Create output image. if output_image_name in bpy.data.images: diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py index aa5b9ebf880..3fc7636459b 100644 --- a/release/scripts/templates_py/operator_mesh_add.py +++ b/release/scripts/templates_py/operator_mesh_add.py @@ -6,6 +6,7 @@ from bpy.props import ( FloatProperty, ) + def add_box(width, height, depth): """ This function takes inputs and returns vertex and face arrays. diff --git a/tests/performance/api/__init__.py b/tests/performance/api/__init__.py index 6f344a41841..2dc9283c44a 100644 --- a/tests/performance/api/__init__.py +++ b/tests/performance/api/__init__.py @@ -5,4 +5,3 @@ from .device import TestDevice, TestMachine from .config import TestEntry, TestQueue, TestConfig from .test import Test, TestCollection from .graph import TestGraph - diff --git a/tests/performance/api/config.py b/tests/performance/api/config.py index 900cac0a0bb..68f4df8d487 100644 --- a/tests/performance/api/config.py +++ b/tests/performance/api/config.py @@ -10,12 +10,14 @@ from typing import Dict, List from .test import TestCollection + def get_build_hash(args: None) -> str: import bpy import sys build_hash = bpy.app.build_hash.decode('utf-8') return '' if build_hash == 'Unknown' else build_hash + @dataclass class TestEntry: """Test to run, a combination of revision, test and device.""" @@ -42,6 +44,7 @@ class TestEntry: for field in self.__dataclass_fields__: setattr(self, field, json_dict[field]) + class TestQueue: """Queue of tests to be run or inspected. Matches JSON file on disk.""" @@ -99,6 +102,7 @@ class TestQueue: with open(self.filepath, 'w') as f: json.dump(json_entries, f, indent=2) + class TestConfig: """Test configuration, containing a subset of revisions, tests and devices.""" diff --git a/tests/performance/api/device.py b/tests/performance/api/device.py index e27540da747..b61ae42be36 100644 --- a/tests/performance/api/device.py +++ b/tests/performance/api/device.py @@ -4,6 +4,7 @@ import platform import subprocess from typing import List + def get_cpu_name() -> str: # Get full CPU name. if platform.system() == "Windows": @@ -19,6 +20,7 @@ def get_cpu_name() -> str: return "Unknown CPU" + def get_gpu_device(args: None) -> List: # Get the list of available Cycles GPU devices. import bpy @@ -41,6 +43,7 @@ def get_gpu_device(args: None) -> List: return result + class TestDevice: def __init__(self, device_type: str, device_id: str, name: str, operating_system: str): self.type = device_type @@ -48,6 +51,7 @@ class TestDevice: self.name = name self.operating_system = operating_system + class TestMachine: def __init__(self, env, need_gpus: bool): operating_system = platform.system() @@ -65,4 +69,3 @@ class TestMachine: def cpu_device(self) -> TestDevice: return self.devices[0] - diff --git a/tests/performance/api/environment.py b/tests/performance/api/environment.py index 7c4e5e761a6..c9ddd493394 100644 --- a/tests/performance/api/environment.py +++ b/tests/performance/api/environment.py @@ -15,6 +15,7 @@ from typing import Callable, Dict, List from .config import TestConfig from .device import TestMachine + class TestEnvironment: def __init__(self, blender_git_dir: pathlib.Path, base_dir: pathlib.Path): self.blender_git_dir = blender_git_dir diff --git a/tests/performance/api/graph.py b/tests/performance/api/graph.py index e2d2e7d2058..eb411915ad9 100644 --- a/tests/performance/api/graph.py +++ b/tests/performance/api/graph.py @@ -6,6 +6,7 @@ import json import pathlib from typing import Dict, List + class TestGraph: def __init__(self, json_filepaths: List[pathlib.Path]): # Initialize graph from JSON file. Note that this is implemented without @@ -102,4 +103,3 @@ class TestGraph: contents = template.replace('%JSON_DATA%', self.json) with open(filepath, "w") as f: f.write(contents) - diff --git a/tests/performance/api/test.py b/tests/performance/api/test.py index 23459b4b421..7e8193d2c21 100644 --- a/tests/performance/api/test.py +++ b/tests/performance/api/test.py @@ -4,6 +4,7 @@ import abc import fnmatch from typing import Dict, List + class Test: @abc.abstractmethod def name(self) -> str: @@ -29,6 +30,7 @@ class Test: Execute the test and report results. """ + class TestCollection: def __init__(self, env, names_filter: List=['*'], categories_filter: List=['*']): import importlib diff --git a/tests/performance/tests/__init__.py b/tests/performance/tests/__init__.py index 69b72d23c3f..ac3e613174f 100644 --- a/tests/performance/tests/__init__.py +++ b/tests/performance/tests/__init__.py @@ -1,2 +1 @@ # Apache License, Version 2.0 - diff --git a/tests/performance/tests/animation.py b/tests/performance/tests/animation.py index de3b8817820..1a92f1a9718 100644 --- a/tests/performance/tests/animation.py +++ b/tests/performance/tests/animation.py @@ -3,6 +3,7 @@ import api import os + def _run(args): import bpy import time @@ -18,6 +19,7 @@ def _run(args): result = {'time': elapsed_time} return result + class AnimationTest(api.Test): def __init__(self, filepath): self.filepath = filepath @@ -33,6 +35,7 @@ class AnimationTest(api.Test): result, _ = env.run_in_blender(_run, args) return result + def generate(env): filepaths = env.find_blend_files('animation') return [AnimationTest(filepath) for filepath in filepaths] diff --git a/tests/performance/tests/blend_load.py b/tests/performance/tests/blend_load.py index 4df8bd774d3..5fe498fd3d7 100644 --- a/tests/performance/tests/blend_load.py +++ b/tests/performance/tests/blend_load.py @@ -4,6 +4,7 @@ import api import os import pathlib + def _run(filepath): import bpy import time @@ -20,6 +21,7 @@ def _run(filepath): result = {'time': elapsed_time} return result + class BlendLoadTest(api.Test): def __init__(self, filepath): self.filepath = filepath @@ -34,6 +36,7 @@ class BlendLoadTest(api.Test): result, _ = env.run_in_blender(_run, str(self.filepath)) return result + def generate(env): filepaths = env.find_blend_files('*/*') return [BlendLoadTest(filepath) for filepath in filepaths] diff --git a/tests/performance/tests/cycles.py b/tests/performance/tests/cycles.py index 185d4e8e6c0..f79e7333458 100644 --- a/tests/performance/tests/cycles.py +++ b/tests/performance/tests/cycles.py @@ -3,6 +3,7 @@ import api import os + def _run(args): import bpy import time @@ -39,6 +40,7 @@ def _run(args): return None + class CyclesTest(api.Test): def __init__(self, filepath): self.filepath = filepath @@ -74,6 +76,7 @@ class CyclesTest(api.Test): raise Exception("Error parsing render time output") + def generate(env): filepaths = env.find_blend_files('cycles-x/*') return [CyclesTest(filepath) for filepath in filepaths] diff --git a/tests/python/bl_animation_fcurves.py b/tests/python/bl_animation_fcurves.py index 2ec04749d70..9017c1ee037 100644 --- a/tests/python/bl_animation_fcurves.py +++ b/tests/python/bl_animation_fcurves.py @@ -40,6 +40,7 @@ class AbstractAnimationTest: self.assertTrue(self.testdir.exists(), 'Test dir %s should exist' % self.testdir) + class FCurveEvaluationTest(AbstractAnimationTest, unittest.TestCase): def test_fcurve_versioning_291(self): # See D8752. diff --git a/tests/python/bl_blendfile_library_overrides.py b/tests/python/bl_blendfile_library_overrides.py index 48625a1ecdb..c9c89c01cee 100644 --- a/tests/python/bl_blendfile_library_overrides.py +++ b/tests/python/bl_blendfile_library_overrides.py @@ -69,7 +69,7 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): assert(len(local_id.override_library.properties) == 1) override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "location"); + assert(override_prop.rna_path == "location") assert(len(override_prop.operations) == 1) override_operation = override_prop.operations[0] assert(override_operation.operation == 'REPLACE') @@ -96,7 +96,7 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): self.assertIsNone(local_id.data.override_library) assert(len(local_id.override_library.properties) == 1) override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "scale"); + assert(override_prop.rna_path == "scale") assert(len(override_prop.operations) == 1) override_operation = override_prop.operations[0] assert(override_operation.operation == 'NOOP') @@ -116,14 +116,14 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): assert(len(local_id.override_library.properties) == 2) override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "scale"); + assert(override_prop.rna_path == "scale") assert(len(override_prop.operations) == 1) override_operation = override_prop.operations[0] assert(override_operation.operation == 'NOOP') assert(override_operation.subitem_local_index == -1) override_prop = local_id.override_library.properties[1] - assert(override_prop.rna_path == "location"); + assert(override_prop.rna_path == "location") assert(len(override_prop.operations) == 1) override_operation = override_prop.operations[0] assert(override_operation.operation == 'REPLACE') diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py index 1e570bf9a7f..38cd9d04a6b 100644 --- a/tests/python/bl_pyapi_idprop.py +++ b/tests/python/bl_pyapi_idprop.py @@ -140,6 +140,7 @@ class TestIdPropertyCreation(TestHelper, unittest.TestCase): with self.assertRaises(TypeError): self.id["a"] = self + class TestIdPropertyGroupView(TestHelper, unittest.TestCase): def test_type(self): diff --git a/tests/python/compositor_render_tests.py b/tests/python/compositor_render_tests.py index 057d4a2e6dd..199e1c13b8e 100644 --- a/tests/python/compositor_render_tests.py +++ b/tests/python/compositor_render_tests.py @@ -16,6 +16,7 @@ try: except ImportError: inside_blender = False + def get_arguments(filepath, output_filepath): return [ "--background", diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py index 36c3f7d9fe5..ca0bc9f18b9 100644 --- a/tests/python/cycles_render_tests.py +++ b/tests/python/cycles_render_tests.py @@ -57,6 +57,7 @@ BLACKLIST_GPU = [ 'transparent_shadow_hair.*.blend', ] + def get_arguments(filepath, output_filepath): dirname = os.path.dirname(filepath) basedir = os.path.dirname(dirname) diff --git a/tests/python/modules/mesh_test.py b/tests/python/modules/mesh_test.py index 1749e798a32..6d921959e6f 100644 --- a/tests/python/modules/mesh_test.py +++ b/tests/python/modules/mesh_test.py @@ -680,7 +680,7 @@ class RunTest: test_name = each_test.test_name if self.verbose: print() - print("Running test {}/{}: {}...".format(test_number+1, len(self.tests), test_name)) + print("Running test {}/{}: {}...".format(test_number + 1, len(self.tests), test_name)) success = self.run_test(test_name) if not success: diff --git a/tests/python/operators.py b/tests/python/operators.py index c209b01c20c..4501df82175 100644 --- a/tests/python/operators.py +++ b/tests/python/operators.py @@ -321,7 +321,7 @@ def main(): MeshTest("CubeEdgeUnsubdivide", "testCubeEdgeUnsubdivide", "expectedCubeEdgeUnsubdivide", [OperatorSpecEditMode("unsubdivide", {}, "EDGE", {i for i in range(6)})]), MeshTest("UVSphereUnsubdivide", "testUVSphereUnsubdivide", "expectedUVSphereUnsubdivide", - [OperatorSpecEditMode("unsubdivide", {'iterations': 9}, "FACE", {i for i in range(512)})]), + [OperatorSpecEditMode("unsubdivide", {'iterations': 9}, "FACE", {i for i in range(512)})]), # vert connect path # Tip: It works only if there is an already existing face or more than 2 vertices.