Cleanup: Python script formatting

- Double quotes for strings.
- Trailing commas when wrapped lines.
This commit is contained in:
Campbell Barton 2024-06-06 11:26:28 +10:00
parent 1d894aa1a7
commit 949dfbfaa8
22 changed files with 57 additions and 54 deletions

@ -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))

@ -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)

@ -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

@ -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

@ -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,
)

@ -79,7 +79,7 @@ def bake_action(
obj,
*,
action, frames,
bake_options: BakeOptions
bake_options: BakeOptions,
):
"""
:arg obj: Object to bake.

@ -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):

@ -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 (

@ -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

@ -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",

@ -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)

@ -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)

@ -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,
)

@ -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(

@ -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.

@ -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):

@ -80,7 +80,7 @@ class TEXT_HT_footer(Header):
text=iface_("Text: External")
if text.library
else iface_("Text: Internal"),
translate=False
translate=False,
)

@ -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)

@ -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:

@ -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: -")

@ -26,7 +26,7 @@ class MyPanel(bpy.types.Panel):
classes = [
MyPropGroup,
MyPanel
MyPanel,
]
class_register, class_unregister = bpy.utils.register_classes_factory(classes)

@ -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