From 949dfbfaa8e4ec466f1397c989f2bf5e3fa5b82c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 Jun 2024 11:26:28 +1000 Subject: [PATCH] Cleanup: Python script formatting - Double quotes for strings. - Trailing commas when wrapped lines. --- doc/python_api/sphinx_doc_gen.py | 2 +- scripts/modules/_bpy_internal/freedesktop.py | 2 +- scripts/modules/addon_utils.py | 2 +- scripts/modules/bl_app_override/__init__.py | 2 +- scripts/modules/bpy/utils/__init__.py | 2 +- scripts/modules/bpy_extras/anim_utils.py | 2 +- scripts/startup/bl_operators/anim.py | 10 +++++----- scripts/startup/bl_operators/image.py | 2 +- scripts/startup/bl_operators/image_as_planes.py | 12 ++++++------ .../startup/bl_operators/object_quick_effects.py | 6 +++--- scripts/startup/bl_operators/presets.py | 6 +++--- scripts/startup/bl_operators/userpref.py | 2 +- scripts/startup/bl_operators/wm.py | 6 +++--- scripts/startup/bl_operators/world.py | 2 +- scripts/startup/bl_ui/generic_ui_list.py | 6 +++--- scripts/startup/bl_ui/properties_texture.py | 8 ++++---- scripts/startup/bl_ui/space_text.py | 2 +- scripts/startup/bl_ui/space_userpref.py | 4 ++-- scripts/startup/bl_ui/space_view3d.py | 13 ++++++++----- scripts/startup/bl_ui/temp_anim_layers.py | 16 ++++++++-------- scripts/templates_py/ui_list_generic.py | 2 +- source/blender/datatoc/datatoc_icon_split.py | 2 +- 22 files changed, 57 insertions(+), 54 deletions(-) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 3e24d851c9c..808f83dda4d 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -1651,7 +1651,7 @@ def pyrna2sphinx(basepath): fw(" .. {:s}:: {:s}({:s})\n\n".format( "classmethod" if func.is_classmethod else "method", func.identifier, - args_str + args_str, )) fw(" {:s}\n\n".format(func.description)) diff --git a/scripts/modules/_bpy_internal/freedesktop.py b/scripts/modules/_bpy_internal/freedesktop.py index 7466f8da053..d4a222b89cd 100644 --- a/scripts/modules/_bpy_internal/freedesktop.py +++ b/scripts/modules/_bpy_internal/freedesktop.py @@ -435,7 +435,7 @@ def call_handle_checked( fn: Callable[[bool, bool], Optional[str]], *, do_register: bool, - all_users: bool + all_users: bool, ) -> Optional[str]: try: result = fn(do_register, all_users) diff --git a/scripts/modules/addon_utils.py b/scripts/modules/addon_utils.py index aa6f76c6e73..f4edb440e80 100644 --- a/scripts/modules/addon_utils.py +++ b/scripts/modules/addon_utils.py @@ -390,7 +390,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non "module loaded with no associated file, __path__={!r}, aborting!".format( getattr(mod, "__path__", None) ), - name=module_name + name=module_name, ) mod.__time__ = os.path.getmtime(mod_file) mod.__addon_enabled__ = False diff --git a/scripts/modules/bl_app_override/__init__.py b/scripts/modules/bl_app_override/__init__.py index 4e8c6ecc541..39f465e7525 100644 --- a/scripts/modules/bl_app_override/__init__.py +++ b/scripts/modules/bl_app_override/__init__.py @@ -31,7 +31,7 @@ def ui_draw_filter_register( ui_ignore_operator=None, ui_ignore_property=None, ui_ignore_menu=None, - ui_ignore_label=None + ui_ignore_label=None, ): import bpy diff --git a/scripts/modules/bpy/utils/__init__.py b/scripts/modules/bpy/utils/__init__.py index 005c7fd7829..820b5b59f72 100644 --- a/scripts/modules/bpy/utils/__init__.py +++ b/scripts/modules/bpy/utils/__init__.py @@ -564,7 +564,7 @@ def smpte_from_seconds(time, *, fps=None, fps_base=None): return smpte_from_frame( time_to_frame(time, fps=fps, fps_base=fps_base), fps=fps, - fps_base=fps_base + fps_base=fps_base, ) diff --git a/scripts/modules/bpy_extras/anim_utils.py b/scripts/modules/bpy_extras/anim_utils.py index 54040398e9e..6ddb70a5efd 100644 --- a/scripts/modules/bpy_extras/anim_utils.py +++ b/scripts/modules/bpy_extras/anim_utils.py @@ -79,7 +79,7 @@ def bake_action( obj, *, action, frames, - bake_options: BakeOptions + bake_options: BakeOptions, ): """ :arg obj: Object to bake. diff --git a/scripts/startup/bl_operators/anim.py b/scripts/startup/bl_operators/anim.py index 18af4eebb63..9aaff27101d 100644 --- a/scripts/startup/bl_operators/anim.py +++ b/scripts/startup/bl_operators/anim.py @@ -115,7 +115,7 @@ class ANIM_OT_keying_set_export(Operator): if not found: self.report( {'WARN'}, - rpt_("Could not find material or light using Shader Node Tree - {:s}").format(str(ksp.id)) + rpt_("Could not find material or light using Shader Node Tree - {:s}").format(str(ksp.id)), ) elif ksp.id.bl_rna.identifier.startswith("CompositorNodeTree"): # Find compositor node-tree using this node tree. @@ -126,7 +126,7 @@ class ANIM_OT_keying_set_export(Operator): else: self.report( {'WARN'}, - rpt_("Could not find scene using Compositor Node Tree - {:s}").format(str(ksp.id)) + rpt_("Could not find scene using Compositor Node Tree - {:s}").format(str(ksp.id)), ) elif ksp.id.bl_rna.name == "Key": # "keys" conflicts with a Python keyword, hence the simple solution won't work @@ -262,7 +262,7 @@ class NLA_OT_bake(Operator): ('ROTATION', "Rotation", "Bake rotation channels"), ('SCALE', "Scale", "Bake scale channels"), ('BBONE', "B-Bone", "Bake B-Bone channels"), - ('PROPS', "Custom Properties", "Bake custom properties") + ('PROPS', "Custom Properties", "Bake custom properties"), ), default={'LOCATION', 'ROTATION', 'SCALE', 'BBONE', 'PROPS'}, ) @@ -282,7 +282,7 @@ class NLA_OT_bake(Operator): do_rotation='ROTATION' in self.channel_types, do_scale='SCALE' in self.channel_types, do_bbone='BBONE' in self.channel_types, - do_custom_props='PROPS' in self.channel_types + do_custom_props='PROPS' in self.channel_types, ) if bake_options.do_pose and self.only_selected: @@ -308,7 +308,7 @@ class NLA_OT_bake(Operator): actions = anim_utils.bake_action_objects( object_action_pairs, frames=range(self.frame_start, self.frame_end + 1, self.step), - bake_options=bake_options + bake_options=bake_options, ) if not any(actions): diff --git a/scripts/startup/bl_operators/image.py b/scripts/startup/bl_operators/image.py index cf350d5ae26..6efebb2f43a 100644 --- a/scripts/startup/bl_operators/image.py +++ b/scripts/startup/bl_operators/image.py @@ -260,7 +260,7 @@ class IMAGE_OT_open_images(Operator): "prefix": file.name[:len(file.name) - len(match.group(0))], "ext": match.group(2), "frame_size": len(match.group(1)), - "files": [file.name] + "files": [file.name], } for test_seq in sequences: if ( diff --git a/scripts/startup/bl_operators/image_as_planes.py b/scripts/startup/bl_operators/image_as_planes.py index 563b7f9e023..dc0794608f9 100644 --- a/scripts/startup/bl_operators/image_as_planes.py +++ b/scripts/startup/bl_operators/image_as_planes.py @@ -22,7 +22,7 @@ from bpy.props import ( from bpy.app.translations import ( pgettext_tip as tip_, - contexts as i18n_contexts + contexts as i18n_contexts, ) from mathutils import Vector @@ -675,7 +675,7 @@ class IMAGE_OT_import_as_mesh_planes(AddObjectHelper, ImportHelper, MaterialProp force_reload: BoolProperty( name="Force Reload", default=False, - description="Force reload the image if it is already opened elsewhere in Blender" + description="Force reload the image if it is already opened elsewhere in Blender", ) image_sequence: BoolProperty( @@ -903,7 +903,7 @@ class IMAGE_OT_import_as_mesh_planes(AddObjectHelper, ImportHelper, MaterialProp (fn.name for fn in self.files), self.directory, force_reload=self.force_reload, - find_sequences=self.image_sequence + find_sequences=self.image_sequence, )) if not images: @@ -1029,7 +1029,7 @@ class IMAGE_OT_import_as_mesh_planes(AddObjectHelper, ImportHelper, MaterialProp elif self.size_mode == 'CAMERA': x, y = compute_camera_size( context, context.scene.cursor.location, - self.fill_mode, px / py + self.fill_mode, px / py, ) elif self.size_mode == 'DPI': @@ -1113,13 +1113,13 @@ class IMAGE_OT_convert_to_mesh_plane(MaterialProperties_MixIn, TextureProperties ('IMAGE', "Source Image", "name from laoded image"), ], default='OBJECT', - description="Name for new mesh object and material" + description="Name for new mesh object and material", ) delete_ref: BoolProperty( name="Delete Reference Object", default=True, - description="Delete empty image object once mesh plane is created" + description="Delete empty image object once mesh plane is created", ) @classmethod diff --git a/scripts/startup/bl_operators/object_quick_effects.py b/scripts/startup/bl_operators/object_quick_effects.py index 4b77144ffc0..7bdc6126fbc 100644 --- a/scripts/startup/bl_operators/object_quick_effects.py +++ b/scripts/startup/bl_operators/object_quick_effects.py @@ -60,20 +60,20 @@ class QuickFur(ObjectModeOperator, Operator): min=0.001, max=100, soft_min=0.01, soft_max=10, default=0.1, - subtype='DISTANCE' + subtype='DISTANCE', ) radius: FloatProperty( name="Hair Radius", min=0.0, max=10, soft_min=0.0001, soft_max=0.1, default=0.001, - subtype='DISTANCE' + subtype='DISTANCE', ) view_percentage: FloatProperty( name="View Percentage", min=0.0, max=1.0, default=1.0, - subtype='FACTOR' + subtype='FACTOR', ) apply_hair_guides: BoolProperty( name="Apply Hair Guides", diff --git a/scripts/startup/bl_operators/presets.py b/scripts/startup/bl_operators/presets.py index a38001883d0..592e80157e9 100644 --- a/scripts/startup/bl_operators/presets.py +++ b/scripts/startup/bl_operators/presets.py @@ -443,7 +443,7 @@ class AddPresetTextEditor(AddPresetBase, Operator): preset_values = [ "filepaths.text_editor", - "filepaths.text_editor_args" + "filepaths.text_editor_args", ] preset_subdir = "text_editor" @@ -539,7 +539,7 @@ class AddPresetEEVEERaytracing(AddPresetBase, Operator): preset_defines = [ "eevee = bpy.context.scene.eevee", - "options = eevee.ray_tracing_options" + "options = eevee.ray_tracing_options", ] preset_values = [ @@ -865,7 +865,7 @@ class WM_OT_operator_presets_cleanup(Operator): "filepath", "directory", "files", - "filename" + "filename", ] self._cleanup_operators_presets(operators, properties_exclude) diff --git a/scripts/startup/bl_operators/userpref.py b/scripts/startup/bl_operators/userpref.py index 4b7c847e685..8c4837d2736 100644 --- a/scripts/startup/bl_operators/userpref.py +++ b/scripts/startup/bl_operators/userpref.py @@ -1046,7 +1046,7 @@ class PREFERENCES_OT_studiolight_install(Operator): # print message msg = rpt_("StudioLight Installed {!r} into {!r}").format( ", ".join(e.name for e in self.files), - path_studiolights + path_studiolights, ) print(msg) self.report({'INFO'}, msg) diff --git a/scripts/startup/bl_operators/wm.py b/scripts/startup/bl_operators/wm.py index d6149e39b70..28bb7f3cfa4 100644 --- a/scripts/startup/bl_operators/wm.py +++ b/scripts/startup/bl_operators/wm.py @@ -1450,7 +1450,7 @@ class WM_OT_properties_edit(Operator): property_type: EnumProperty( name="Type", items=rna_custom_property_type_items, - update=property_type_update_cb + update=property_type_update_cb, ) is_overridable_library: BoolProperty( name="Library Overridable", @@ -3374,7 +3374,7 @@ class WM_MT_splash_about(Menu): col.label(text=iface_("Date: {:s} {:s}").format( bpy.app.build_commit_date.decode("utf-8", "replace"), bpy.app.build_commit_time.decode("utf-8", "replace")), - translate=False + translate=False, ) col.label(text=iface_("Hash: {:s}").format(bpy.app.build_hash.decode("ascii")), translate=False) col.label(text=iface_("Branch: {:s}").format(bpy.app.build_branch.decode("utf-8", "replace")), translate=False) @@ -3592,5 +3592,5 @@ classes = ( WM_MT_splash_quick_setup, WM_MT_splash, WM_MT_splash_about, - WM_MT_region_toggle_pie + WM_MT_region_toggle_pie, ) diff --git a/scripts/startup/bl_operators/world.py b/scripts/startup/bl_operators/world.py index 35686d306c7..ba5d07be6f7 100644 --- a/scripts/startup/bl_operators/world.py +++ b/scripts/startup/bl_operators/world.py @@ -112,7 +112,7 @@ class WORLD_OT_convert_volume_to_mesh(bpy.types.Operator): from_socket_index = src_node.outputs.find(src_link.from_socket.name) dst_tree.links.new( dst_linked_node.outputs[from_socket_index], - dst_socket + dst_socket, ) def _sync_node( diff --git a/scripts/startup/bl_ui/generic_ui_list.py b/scripts/startup/bl_ui/generic_ui_list.py index f97e2d0c553..48253ca4a16 100644 --- a/scripts/startup/bl_ui/generic_ui_list.py +++ b/scripts/startup/bl_ui/generic_ui_list.py @@ -84,7 +84,7 @@ def draw_ui_list( list_owner, list_prop_name, index_owner, index_prop_name, rows=4 if list_to_draw else 1, - **kwargs + **kwargs, ) col = row.column() @@ -94,7 +94,7 @@ def draw_ui_list( layout=col, list_path=list_path, active_index_path=active_index_path, - list_length=len(list_to_draw) + list_length=len(list_to_draw), ) layout.separator() @@ -107,7 +107,7 @@ def draw_ui_list( layout=col, list_path=list_path, active_index_path=active_index_path, - list_length=len(list_to_draw) + list_length=len(list_to_draw), ) # Return the right-side column. diff --git a/scripts/startup/bl_ui/properties_texture.py b/scripts/startup/bl_ui/properties_texture.py index 63283dbccf2..d783adfffd4 100644 --- a/scripts/startup/bl_ui/properties_texture.py +++ b/scripts/startup/bl_ui/properties_texture.py @@ -441,7 +441,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel): 'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', - 'BLENDER_WORKBENCH' + 'BLENDER_WORKBENCH', } def draw(self, context): @@ -476,7 +476,7 @@ class TEXTURE_PT_image_alpha(TextureTypePanel, Panel): 'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', - 'BLENDER_WORKBENCH' + 'BLENDER_WORKBENCH', } def draw_header(self, context): @@ -504,7 +504,7 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, Panel): 'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', - 'BLENDER_WORKBENCH' + 'BLENDER_WORKBENCH', } def draw(self, context): @@ -561,7 +561,7 @@ class TEXTURE_PT_image_mapping_crop(TextureTypePanel, Panel): 'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', - 'BLENDER_WORKBENCH' + 'BLENDER_WORKBENCH', } def draw(self, context): diff --git a/scripts/startup/bl_ui/space_text.py b/scripts/startup/bl_ui/space_text.py index ef9b1e9d60c..8f8001cfea3 100644 --- a/scripts/startup/bl_ui/space_text.py +++ b/scripts/startup/bl_ui/space_text.py @@ -80,7 +80,7 @@ class TEXT_HT_footer(Header): text=iface_("Text: External") if text.library else iface_("Text: Internal"), - translate=False + translate=False, ) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 8671cab04c5..9cd3e2fb689 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -1642,7 +1642,7 @@ class USERPREF_PT_file_paths_asset_libraries(FilePathsPanel, Panel): row.template_list( "USERPREF_UL_asset_libraries", "user_asset_libraries", paths, "asset_libraries", - paths, "active_asset_library" + paths, "active_asset_library", ) col = row.column(align=True) @@ -2145,7 +2145,7 @@ class USERPREF_PT_extensions_repos(Panel): row.template_list( "USERPREF_UL_extension_repos", "user_extension_repos", extensions, "repos", - extensions, "active_repo" + extensions, "active_repo", ) col = row.column(align=True) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 71a086bf46d..d3b797e8392 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -1058,7 +1058,7 @@ class VIEW3D_HT_header(Header): layout.popover( panel="VIEW3D_PT_gpencil_sculpt_automasking", text="", - icon=VIEW3D_HT_header._gpencil_sculpt_automasking_icon(tool_settings.gpencil_sculpt) + icon=VIEW3D_HT_header._gpencil_sculpt_automasking_icon(tool_settings.gpencil_sculpt), ) elif object_mode == 'SCULPT': @@ -1090,7 +1090,7 @@ class VIEW3D_HT_header(Header): layout.popover( panel="VIEW3D_PT_sculpt_automasking", text="", - icon=VIEW3D_HT_header._sculpt_automasking_icon(tool_settings.sculpt) + icon=VIEW3D_HT_header._sculpt_automasking_icon(tool_settings.sculpt), ) elif object_mode == 'VERTEX_PAINT': @@ -3502,8 +3502,11 @@ class VIEW3D_MT_object_convert(Menu): ob = context.active_object if ob and ob.type != "EMPTY": - if (ob.type == 'GPENCIL' and context.gpencil_data - and not context.preferences.experimental.use_grease_pencil_version3): + if ( + (ob.type == 'GPENCIL') and + (context.gpencil_data is not None) and + (not context.preferences.experimental.use_grease_pencil_version3) + ): layout.operator_enum("gpencil.convert", "type") else: layout.operator_enum("object.convert", "target") @@ -3828,7 +3831,7 @@ class VIEW3D_MT_sculpt(Menu): ('SHARPEN', iface_("Sharpen")), ('ENHANCE_DETAILS', iface_("Enhance Details")), ('ERASE_DISCPLACEMENT', iface_("Erase Multires Displacement")), - ('RANDOM', iface_("Randomize")) + ('RANDOM', iface_("Randomize")), ] for filter_type, ui_name in sculpt_filters_types: diff --git a/scripts/startup/bl_ui/temp_anim_layers.py b/scripts/startup/bl_ui/temp_anim_layers.py index 776634c528c..97f5637a736 100644 --- a/scripts/startup/bl_ui/temp_anim_layers.py +++ b/scripts/startup/bl_ui/temp_anim_layers.py @@ -35,7 +35,7 @@ class VIEW3D_PT_animation_layers(Panel): # FIXME: this should be done in response to a message-bus callback, notifier, whatnot. adt = context.object.animation_data with _wm_selected_action_lock: - selected_action = getattr(adt, 'action', None) + selected_action = getattr(adt, "action", None) # Only set if it has to change, to avoid unnecessary notifies (that cause # a redraw, that cause this code to be called, etc.) if context.window_manager.selected_action != selected_action: @@ -45,7 +45,7 @@ class VIEW3D_PT_animation_layers(Panel): # This has to go via an auxiliary property, as assigning an Animation # data-block should be possible even when `context.object.animation_data` # is `None`, and thus its `animation` property does not exist. - col.template_ID(context.window_manager, 'selected_action') + col.template_ID(context.window_manager, "selected_action") col = layout.column(align=False) anim = adt and adt.action @@ -54,21 +54,21 @@ class VIEW3D_PT_animation_layers(Panel): # Binding selector. row = binding_sub.row(align=True) - row.prop(adt, 'action_binding', text="Binding") - row.operator('anim.binding_unassign_object', text="", icon='X') + row.prop(adt, "action_binding", text="Binding") + row.operator("anim.binding_unassign_object", text="", icon='X') binding = anim.bindings.get(adt.action_binding, None) if binding: - binding_sub.prop(binding, 'name_display', text="Name") + binding_sub.prop(binding, "name_display", text="Name") internal_sub = binding_sub.box().column(align=True) internal_sub.active = False - internal_sub.prop(adt, 'action_binding_handle', text="handle") + internal_sub.prop(adt, "action_binding_handle", text="handle") if binding: - internal_sub.prop(binding, 'name', text="Internal Name") + internal_sub.prop(binding, "name", text="Internal Name") if adt: - col.prop(adt, 'action_binding_name', text="ADT Binding Name") + col.prop(adt, "action_binding_name", text="ADT Binding Name") else: col.label(text="ADT Binding Name: -") diff --git a/scripts/templates_py/ui_list_generic.py b/scripts/templates_py/ui_list_generic.py index 4113a99d681..fbcd6a6966f 100644 --- a/scripts/templates_py/ui_list_generic.py +++ b/scripts/templates_py/ui_list_generic.py @@ -26,7 +26,7 @@ class MyPanel(bpy.types.Panel): classes = [ MyPropGroup, - MyPanel + MyPanel, ] class_register, class_unregister = bpy.utils.register_classes_factory(classes) diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py index 73900e1f117..177314b048d 100755 --- a/source/blender/datatoc/datatoc_icon_split.py +++ b/source/blender/datatoc/datatoc_icon_split.py @@ -197,7 +197,7 @@ def dice( id_str = dice_icon_name( x, y, parts_x, parts_y, - name_style=name_style, prefix=output_prefix + name_style=name_style, prefix=output_prefix, ) if not id_str: continue