From b4fbc0c32d6862c2c391c7cdf910f48cdd9d8dbe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Sep 2025 14:28:46 +1000 Subject: [PATCH] Cleanup: remove f-strings use, use double quotes, quiet pylint warnings --- .../Storyboarding/__init__.py | 2 +- .../bl_operators/bone_selection_sets.py | 8 ++-- scripts/startup/bl_operators/node.py | 44 +++++++++++++------ .../node_editor/node_functions.py | 2 +- scripts/startup/bl_ui/node_add_menu.py | 7 ++- .../startup/bl_ui/node_add_menu_compositor.py | 2 +- .../startup/bl_ui/node_add_menu_geometry.py | 9 +++- scripts/startup/bl_ui/node_add_menu_shader.py | 2 +- .../startup/bl_ui/node_add_menu_texture.py | 1 + scripts/startup/bl_ui/properties_texture.py | 2 +- scripts/startup/bl_ui/space_node.py | 2 +- scripts/startup/bl_ui/space_userpref.py | 4 +- 12 files changed, 55 insertions(+), 30 deletions(-) diff --git a/scripts/startup/bl_app_templates_system/Storyboarding/__init__.py b/scripts/startup/bl_app_templates_system/Storyboarding/__init__.py index 1336d7c6150..09a3b19fbaf 100644 --- a/scripts/startup/bl_app_templates_system/Storyboarding/__init__.py +++ b/scripts/startup/bl_app_templates_system/Storyboarding/__init__.py @@ -35,7 +35,7 @@ def update_factory_startup_scenes(): scene.tool_settings.use_keyframe_insert_auto = True scene.tool_settings.gpencil_sculpt.use_scale_thickness = True - if scene.name == 'Edit': + if scene.name == "Edit": scene.tool_settings.use_keyframe_insert_auto = False diff --git a/scripts/startup/bl_operators/bone_selection_sets.py b/scripts/startup/bl_operators/bone_selection_sets.py index 635cc930220..f2be9944755 100644 --- a/scripts/startup/bl_operators/bone_selection_sets.py +++ b/scripts/startup/bl_operators/bone_selection_sets.py @@ -230,9 +230,9 @@ class POSE_OT_selection_set_select(_NeedSelSetMixin, Operator): bl_options = {'UNDO', 'REGISTER'} selection_set_index: IntProperty( - name='Selection Set Index', + name="Selection Set Index", default=-1, - description='Which Selection Set to select; -1 uses the active Selection Set', + description="Which Selection Set to select; -1 uses the active Selection Set", options={'HIDDEN'}, ) @@ -289,7 +289,7 @@ class POSE_OT_selection_set_copy(_NeedSelSetMixin, Operator): def execute(self, context): context.window_manager.clipboard = _to_json(context) - self.report({'INFO'}, 'Copied Selection Set(s) to clipboard') + self.report({'INFO'}, "Copied Selection Set(s) to clipboard") return {'FINISHED'} @@ -305,7 +305,7 @@ class POSE_OT_selection_set_paste(_PoseModeOnlyMixin, Operator): try: _from_json(context, context.window_manager.clipboard) except (json.JSONDecodeError, KeyError): - self.report({'ERROR'}, 'The clipboard does not contain a Selection Set') + self.report({'ERROR'}, "The clipboard does not contain a Selection Set") else: # Select the pasted Selection Set. context.object.active_selection_set = len(context.object.selection_sets) - 1 diff --git a/scripts/startup/bl_operators/node.py b/scripts/startup/bl_operators/node.py index ee61f8cd97c..8da92100b6f 100644 --- a/scripts/startup/bl_operators/node.py +++ b/scripts/startup/bl_operators/node.py @@ -66,11 +66,20 @@ def cast_value(source, target): value = source.default_value - def to_bool(value): return value > 0 - def single_value_to_color(value): return Vector((value, value, value, 1.0)) - def single_value_to_vector(value): return Vector([value,] * len(target.default_value)) - def color_to_float(color): return (0.2126 * color[0]) + (0.7152 * color[1]) + (0.0722 * color[2]) - def vector_to_float(vector): return sum(vector) / len(vector) + def to_bool(value): + return value > 0 + + def single_value_to_color(value): + return Vector((value, value, value, 1.0)) + + def single_value_to_vector(value): + return Vector([value,] * len(target.default_value)) + + def color_to_float(color): + return (0.2126 * color[0]) + (0.7152 * color[1]) + (0.0722 * color[2]) + + def vector_to_float(vector): + return sum(vector) / len(vector) func_map = { ('VALUE', 'INT'): int, @@ -289,7 +298,7 @@ class NodeSwapOperator(NodeOperator): new_socket = new_node.inputs[input.name] new_value = cast_value(source=input, target=new_socket) - settings_name = f'inputs["{input.name}"].default_value' + settings_name = "inputs[\"{:s}\"].default_value".format(input.name) already_defined = (settings_name in self.settings) if (new_value is not None) and not already_defined: @@ -370,8 +379,9 @@ class NodeSwapOperator(NodeOperator): if switch_type == "GeometryNodeMenuSwitch": return node.enum_definition.enum_items - elif switch_type == "GeometryNodeIndexSwitch": + if switch_type == "GeometryNodeIndexSwitch": return node.index_switch_items + return None def transfer_switch_data(self, old_node, new_node): old_switch_items = self.get_switch_items(old_node) @@ -605,11 +615,19 @@ class ZoneOperator: default=(150, 0), ) - zone_tooltips = { - "GeometryNodeSimulationInput": "Simulate the execution of nodes across a time span", - "GeometryNodeRepeatInput": "Execute nodes with a dynamic number of repetitions", - "GeometryNodeForeachGeometryElementInput": "Perform operations separately for each geometry element (e.g. vertices, edges, etc.)", - "NodeClosureInput": "Wrap nodes inside a closure that can be executed at a different part of the nodetree", + _zone_tooltips = { + "GeometryNodeSimulationInput": ( + "Simulate the execution of nodes across a time span" + ), + "GeometryNodeRepeatInput": ( + "Execute nodes with a dynamic number of repetitions" + ), + "GeometryNodeForeachGeometryElementInput": ( + "Perform operations separately for each geometry element (e.g. vertices, edges, etc.)" + ), + "NodeClosureInput": ( + "Wrap nodes inside a closure that can be executed at a different part of the nodetree" + ), } @classmethod @@ -620,7 +638,7 @@ class ZoneOperator: if input_node_type is None: input_node_type = cls.input_node_type - return cls.zone_tooltips.get(input_node_type, None) + return cls._zone_tooltips.get(input_node_type, None) class NodeAddZoneOperator(ZoneOperator, NodeAddOperator): diff --git a/scripts/startup/bl_operators/node_editor/node_functions.py b/scripts/startup/bl_operators/node_editor/node_functions.py index 6de834e517c..396a8cd985b 100644 --- a/scripts/startup/bl_operators/node_editor/node_functions.py +++ b/scripts/startup/bl_operators/node_editor/node_functions.py @@ -24,7 +24,7 @@ def node_editor_poll(cls, context): def node_space_type_poll(cls, context, types): if context.space_data.tree_type not in types: - tree_types_str = ", ".join(t.split('NodeTree')[0].lower() for t in sorted(types)) + tree_types_str = ", ".join(t.split("NodeTree")[0].lower() for t in sorted(types)) poll_message = tip_( "Current node tree type not supported.\n" "Should be one of {:s}." diff --git a/scripts/startup/bl_ui/node_add_menu.py b/scripts/startup/bl_ui/node_add_menu.py index 5d47847192d..2ce04ab5831 100644 --- a/scripts/startup/bl_ui/node_add_menu.py +++ b/scripts/startup/bl_ui/node_add_menu.py @@ -13,12 +13,10 @@ __all__ = ( "add_repeat_zone", "add_simulation_zone", "draw_node_group_add_menu", - "draw_root_assets", ) import bpy from bpy.types import Menu -from bl_ui import node_add_menu from bpy.app.translations import ( pgettext_iface as iface_, contexts as i18n_contexts, @@ -183,7 +181,8 @@ class NodeMenu(Menu): node_idname, socket_identifier, enum_names, - search_weight=0.0): + search_weight=0.0, + ): """Similar to `node_operator`, but with extra entries based on a enum socket while in search""" operators = [] operators.append(cls.node_operator(layout, node_idname, search_weight=search_weight)) @@ -197,7 +196,7 @@ class NodeMenu(Menu): translate=False, search_weight=search_weight) prop = props.settings.add() - prop.name = f'inputs["{socket_identifier}"].default_value' + prop.name = "inputs[\"{:s}\"].default_value".format(socket_identifier) prop.value = repr(enum_name) operators.append(props) diff --git a/scripts/startup/bl_ui/node_add_menu_compositor.py b/scripts/startup/bl_ui/node_add_menu_compositor.py index c384f0667e0..9c5e1550182 100644 --- a/scripts/startup/bl_ui/node_add_menu_compositor.py +++ b/scripts/startup/bl_ui/node_add_menu_compositor.py @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -from bpy.types import Menu from bl_ui import node_add_menu from bpy.app.translations import ( contexts as i18n_contexts, @@ -318,6 +317,7 @@ class NODE_MT_compositor_node_all_base(node_add_menu.NodeMenu): # & Swap menus can share the same layout while each using their # corresponding menus def draw(self, context): + del context layout = self.layout self.draw_menu(layout, "Input") self.draw_menu(layout, "Output") diff --git a/scripts/startup/bl_ui/node_add_menu_geometry.py b/scripts/startup/bl_ui/node_add_menu_geometry.py index d09695e0687..fcdaf7c58e4 100644 --- a/scripts/startup/bl_ui/node_add_menu_geometry.py +++ b/scripts/startup/bl_ui/node_add_menu_geometry.py @@ -3,7 +3,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later import bpy -from bpy.types import Menu from bl_ui import node_add_menu from bpy.app.translations import ( contexts as i18n_contexts, @@ -396,6 +395,7 @@ class NODE_MT_gn_input_gizmo_base(node_add_menu.NodeMenu): menu_path = "Input/Gizmo" def draw(self, context): + del context layout = self.layout self.node_operator(layout, "GeometryNodeGizmoDial") self.node_operator(layout, "GeometryNodeGizmoLinear") @@ -710,6 +710,7 @@ class NODE_MT_gn_utilities_deprecated_base(node_add_menu.NodeMenu): menu_path = "Utilities/Deprecated" def draw(self, context): + del context layout = self.layout self.node_operator(layout, "FunctionNodeAlignEulerToVector") self.node_operator(layout, "FunctionNodeRotateEuler") @@ -780,6 +781,7 @@ class NODE_MT_category_utilities_bundle_base(node_add_menu.NodeMenu): menu_path = "Utilities/Bundle" def draw(self, context): + del context layout = self.layout self.node_operator(layout, "NodeCombineBundle") self.node_operator(layout, "NodeSeparateBundle") @@ -792,6 +794,7 @@ class NODE_MT_category_utilities_closure_base(node_add_menu.NodeMenu): menu_path = "Utilities/Closure" def draw(self, context): + del context layout = self.layout self.closure_zone(layout, label="Closure") self.node_operator(layout, "NodeEvaluateClosure") @@ -890,6 +893,7 @@ class NODE_MT_gn_volume_read_base(node_add_menu.NodeMenu): menu_path = "Volume/Read" def draw(self, context): + del context layout = self.layout self.node_operator(layout, "GeometryNodeGetNamedGrid") self.node_operator(layout, "GeometryNodeGridInfo") @@ -913,6 +917,7 @@ class NODE_MT_gn_volume_sample_base(node_add_menu.NodeMenu): menu_path = "Volume/Sample" def draw(self, context): + del context layout = self.layout self.node_operator(layout, "GeometryNodeSampleGrid") self.node_operator(layout, "GeometryNodeSampleGridIndex") @@ -939,6 +944,7 @@ class NODE_MT_gn_volume_primitives_base(node_add_menu.NodeMenu): menu_path = "Volume/Primitives" def draw(self, context): + del context layout = self.layout self.node_operator(layout, "GeometryNodeVolumeCube") @@ -953,6 +959,7 @@ class NODE_MT_gn_all_base(node_add_menu.NodeMenu): # & Swap menus can share the same layout while each using their # corresponding menus def draw(self, context): + del context layout = self.layout self.draw_menu(layout, "Attribute") self.draw_menu(layout, "Input") diff --git a/scripts/startup/bl_ui/node_add_menu_shader.py b/scripts/startup/bl_ui/node_add_menu_shader.py index 6eea092485f..17e71b3c12d 100644 --- a/scripts/startup/bl_ui/node_add_menu_shader.py +++ b/scripts/startup/bl_ui/node_add_menu_shader.py @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -from bpy.types import Menu from bl_ui import node_add_menu from bpy.app.translations import ( contexts as i18n_contexts, @@ -412,6 +411,7 @@ class NODE_MT_shader_node_all_base(node_add_menu.NodeMenu): # & Swap menus can share the same layout while each using their # corresponding menus def draw(self, context): + del context layout = self.layout self.draw_menu(layout, "Input") self.draw_menu(layout, "Output") diff --git a/scripts/startup/bl_ui/node_add_menu_texture.py b/scripts/startup/bl_ui/node_add_menu_texture.py index 5846e8e06c9..c6b639b04fa 100644 --- a/scripts/startup/bl_ui/node_add_menu_texture.py +++ b/scripts/startup/bl_ui/node_add_menu_texture.py @@ -102,6 +102,7 @@ class NODE_MT_texture_node_all_base(node_add_menu.NodeMenu): # & Swap menus can share the same layout while each using their # corresponding menus def draw(self, context): + del context layout = self.layout self.draw_menu(layout, "Input") self.draw_menu(layout, "Output") diff --git a/scripts/startup/bl_ui/properties_texture.py b/scripts/startup/bl_ui/properties_texture.py index 17695f0cda1..52b3d6c8e7c 100644 --- a/scripts/startup/bl_ui/properties_texture.py +++ b/scripts/startup/bl_ui/properties_texture.py @@ -925,7 +925,7 @@ class TEXTURE_PT_animation(TextureButtonsPanel, PropertiesAnimationMixin, Proper texture = context.texture # Assumption: the texture user is a particle system texture slot, - # something like `bpy.data.particles['ParticleSettings'].texture_slots[0]`. + # something like `bpy.data.particles["ParticleSettings"].texture_slots[0]`. # Since at the top of the properties panel the user is shown first, and # underneath that the texture itself, this panel uses the same order. if texture_user := context.texture_user: diff --git a/scripts/startup/bl_ui/space_node.py b/scripts/startup/bl_ui/space_node.py index 98453ce6780..69e107bba72 100644 --- a/scripts/startup/bl_ui/space_node.py +++ b/scripts/startup/bl_ui/space_node.py @@ -233,7 +233,7 @@ class NODE_HT_header(Header): class NODE_PT_gizmo_display(Panel): bl_space_type = 'NODE_EDITOR' bl_region_type = 'HEADER' - bl_label = 'Gizmos' + bl_label = "Gizmos" bl_ui_units_x = 8 def draw(self, context): diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index a1739aa5d3a..c2def125072 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -59,7 +59,7 @@ class USERPREF_PT_navigation_bar(Panel): bl_label = "Preferences Navigation" bl_space_type = 'PREFERENCES' bl_region_type = 'UI' - bl_category = 'Navigation' + bl_category = "Navigation" bl_options = {'HIDE_HEADER'} def draw(self, context): @@ -706,7 +706,7 @@ class USERPREF_PT_system_display_graphics(SystemPanel, CenterAlignMixIn, Panel): @classmethod def poll(cls, _context): import platform - return platform.system() != 'Darwin' + return platform.system() != "Darwin" def draw_centered(self, context, layout): prefs = context.preferences