Cleanup: remove f-strings use, use double quotes, quiet pylint warnings
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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}."
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user