diff --git a/doc/blender_file_format/BlendFileDnaExporter_25.py b/doc/blender_file_format/BlendFileDnaExporter_25.py index 2106f872a40..b8b8d0918ed 100755 --- a/doc/blender_file_format/BlendFileDnaExporter_25.py +++ b/doc/blender_file_format/BlendFileDnaExporter_25.py @@ -229,7 +229,7 @@ class DNACatalogHTML: return structure_field - def indent(self, input, dent, startswith=''): + def indent(self, input, dent): output = '' if dent < 0: for line in input.split('\n'): diff --git a/doc/python_api/sphinx_doc_gen_monkeypatch.py b/doc/python_api/sphinx_doc_gen_monkeypatch.py index c8098efa175..9a35d9e3c06 100644 --- a/doc/python_api/sphinx_doc_gen_monkeypatch.py +++ b/doc/python_api/sphinx_doc_gen_monkeypatch.py @@ -15,7 +15,7 @@ def main(): import bpy from bpy.types import Operator - def dummy_func(test): + def dummy_func(_test): pass kw_dummy = dict(fget=dummy_func, fset=dummy_func, fdel=dummy_func) diff --git a/scripts/modules/bpy_restrict_state.py b/scripts/modules/bpy_restrict_state.py index fc9f1743d35..4fc5247c560 100644 --- a/scripts/modules/bpy_restrict_state.py +++ b/scripts/modules/bpy_restrict_state.py @@ -45,6 +45,6 @@ class RestrictBlend: _bpy.data = _data_restrict _bpy.context = _context_restrict - def __exit__(self, type, value, traceback): + def __exit__(self, _type, _value, _traceback): _bpy.data = self.data _bpy.context = self.context diff --git a/scripts/modules/console_python.py b/scripts/modules/console_python.py index c596311bfe6..6e4d2e7a43f 100644 --- a/scripts/modules/console_python.py +++ b/scripts/modules/console_python.py @@ -31,7 +31,7 @@ class _TempModuleOverride: self.module = sys.modules.get(self.module_name) sys.modules[self.module_name] = self.module_override - def __exit__(self, type, value, traceback): + def __exit__(self, _type, _value, _traceback): if self.module is None: # Account for removal of `module_override` (albeit unlikely). sys.modules.pop(self.module_name, None) diff --git a/scripts/modules/nodeitems_utils.py b/scripts/modules/nodeitems_utils.py index e0434e463ac..78c485ef4ef 100644 --- a/scripts/modules/nodeitems_utils.py +++ b/scripts/modules/nodeitems_utils.py @@ -99,7 +99,7 @@ _node_categories = {} def register_node_categories(identifier, cat_list): if identifier in _node_categories: raise KeyError("Node categories list '{:s}' already registered".format(identifier)) - return + # return # works as draw function for menus def draw_node_item(self, context): diff --git a/scripts/modules/rna_xml.py b/scripts/modules/rna_xml.py index 3a0fcac8ca7..292a666c61a 100644 --- a/scripts/modules/rna_xml.py +++ b/scripts/modules/rna_xml.py @@ -350,7 +350,7 @@ def xml2rna( # print(elems) if len(elems) == 1: # sub node named by its type - child_xml_real, = elems + child_xml_real = elems[0] # print(child_xml_real, subvalue) xml2rna_node(child_xml_real, subvalue) diff --git a/scripts/startup/bl_operators/anim.py b/scripts/startup/bl_operators/anim.py index 6e8e0441a3d..9e1aab6765f 100644 --- a/scripts/startup/bl_operators/anim.py +++ b/scripts/startup/bl_operators/anim.py @@ -392,7 +392,7 @@ class UpdateAnimatedTransformConstraint(Operator): to_paths = {"to_max_x", "to_max_y", "to_max_z", "to_min_x", "to_min_y", "to_min_z"} paths = from_paths | to_paths - def update_cb(base, class_name, old_path, fcurve, options): + def update_cb(base, _class_name, old_path, fcurve, options): # print(options) def handle_deg2rad(fcurve): diff --git a/scripts/startup/bl_operators/bone_selection_sets.py b/scripts/startup/bl_operators/bone_selection_sets.py index b23e56b6202..af6e77b500a 100644 --- a/scripts/startup/bl_operators/bone_selection_sets.py +++ b/scripts/startup/bl_operators/bone_selection_sets.py @@ -174,7 +174,7 @@ class POSE_OT_selection_set_assign(_PoseModeOnlyMixin, Operator): bl_description = "Add selected bones to Selection Set" bl_options = {'UNDO', 'REGISTER'} - def invoke(self, context, event): + def invoke(self, context, _event): arm = context.object if not (arm.active_selection_set < len(arm.selection_sets)): diff --git a/scripts/startup/bl_operators/uvcalc_transform.py b/scripts/startup/bl_operators/uvcalc_transform.py index bcdc593e4a8..6a627e4e366 100644 --- a/scripts/startup/bl_operators/uvcalc_transform.py +++ b/scripts/startup/bl_operators/uvcalc_transform.py @@ -217,7 +217,7 @@ def align_uv_rotation_island(bm, uv_layer, faces, method, axis, aspect_y): return True -def align_uv_rotation_bmesh(mesh, bm, method, axis, aspect_y): +def align_uv_rotation_bmesh(bm, method, axis, aspect_y): import bpy_extras.bmesh_utils uv_layer = bm.loops.layers.uv.active @@ -260,7 +260,7 @@ def align_uv_rotation(context, method, axis, correct_aspect): for ob in ob_list: bm = bmesh.from_edit_mesh(ob.data) if bm.loops.layers.uv: - if align_uv_rotation_bmesh(ob.data, bm, method, axis, aspect_y): + if align_uv_rotation_bmesh(bm, method, axis, aspect_y): bmesh.update_edit_mesh(ob.data) return {'FINISHED'} diff --git a/scripts/startup/bl_ui/__init__.py b/scripts/startup/bl_ui/__init__.py index 40ec518b7ac..bdc032ee7d9 100644 --- a/scripts/startup/bl_ui/__init__.py +++ b/scripts/startup/bl_ui/__init__.py @@ -266,7 +266,7 @@ class UI_MT_list_item_context_menu(bpy.types.Menu): bl_label = "List Item" bl_idname = "UI_MT_list_item_context_menu" - def draw(self, context): + def draw(self, _context): # Dummy function. This type is just for scripts to append their own # context menu items. pass @@ -282,7 +282,7 @@ class UI_MT_button_context_menu(bpy.types.Menu): bl_label = "List Item" bl_idname = "UI_MT_button_context_menu" - def draw(self, context): + def draw(self, _context): # Draw menu entries created with the legacy `WM_MT_button_context` class. # This is deprecated, and support will be removed in a future release. if hasattr(bpy.types, "WM_MT_button_context"): diff --git a/scripts/startup/bl_ui/anim.py b/scripts/startup/bl_ui/anim.py index f3f9d61de40..b91f66e871f 100644 --- a/scripts/startup/bl_ui/anim.py +++ b/scripts/startup/bl_ui/anim.py @@ -8,7 +8,7 @@ from bpy.types import Menu class ANIM_MT_keyframe_insert_pie(Menu): bl_label = "Keyframe Insert Pie" - def draw(self, context): + def draw(self, _context): layout = self.layout pie = layout.menu_pie() diff --git a/scripts/startup/bl_ui/properties_data_armature.py b/scripts/startup/bl_ui/properties_data_armature.py index 66ac64411db..67eb9974a85 100644 --- a/scripts/startup/bl_ui/properties_data_armature.py +++ b/scripts/startup/bl_ui/properties_data_armature.py @@ -379,7 +379,7 @@ class POSE_PT_selection_sets(Panel): class POSE_UL_selection_set(UIList): - def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): + def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index): row = layout.row() row.prop(item, "name", text="", emboss=False) if self.layout_type in ('DEFAULT', 'COMPACT'): @@ -389,7 +389,7 @@ class POSE_UL_selection_set(UIList): class POSE_MT_selection_set_create(Menu): bl_label = "Choose Selection Set" - def draw(self, context): + def draw(self, _context): layout = self.layout layout.operator("pose.selection_set_add_and_assign", text="New Selection Set") diff --git a/scripts/startup/bl_ui/properties_data_modifier.py b/scripts/startup/bl_ui/properties_data_modifier.py index 5990186ad57..d00e4aa839e 100644 --- a/scripts/startup/bl_ui/properties_data_modifier.py +++ b/scripts/startup/bl_ui/properties_data_modifier.py @@ -294,7 +294,7 @@ class AddModifierMenu(Operator): return False return space and space.type == 'PROPERTIES' and space.context == 'MODIFIER' - def invoke(self, context, event): + def invoke(self, _context, _event): return bpy.ops.wm.call_menu(name="OBJECT_MT_modifier_add") diff --git a/scripts/startup/bl_ui/properties_grease_pencil_common.py b/scripts/startup/bl_ui/properties_grease_pencil_common.py index 89faed1fd82..d9d3a10e209 100644 --- a/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -785,7 +785,7 @@ class GREASE_PENCIL_MT_draw_delete(Menu): class GREASE_PENCIL_MT_stroke_simplify(Menu): bl_label = "Simplify Stroke" - def draw(self, context): + def draw(self, _context): layout = self.layout layout.operator("grease_pencil.stroke_simplify", text="Fixed").mode = 'FIXED' layout.operator("grease_pencil.stroke_simplify", text="Adaptive").mode = 'ADAPTIVE' diff --git a/scripts/startup/bl_ui/properties_workspace.py b/scripts/startup/bl_ui/properties_workspace.py index eebfcde39cc..08318e1c3e6 100644 --- a/scripts/startup/bl_ui/properties_workspace.py +++ b/scripts/startup/bl_ui/properties_workspace.py @@ -149,7 +149,7 @@ class WORKSPACE_UL_addons_items(UIList): indices = self._sort_addons_by_category_name(addons) return flags, indices - def draw_item(self, context, layout, _data, addon, icon, _active_data, _active_propname, _index): + def draw_item(self, context, layout, _data, addon, _icon, _active_data, _active_propname, _index): row = layout.row() row.active = context.workspace.use_filter_by_owner row.emboss = 'NONE' diff --git a/scripts/startup/bl_ui/space_statusbar.py b/scripts/startup/bl_ui/space_statusbar.py index bbe76197f0a..a537446bb31 100644 --- a/scripts/startup/bl_ui/space_statusbar.py +++ b/scripts/startup/bl_ui/space_statusbar.py @@ -8,7 +8,7 @@ from bpy.types import Header class STATUSBAR_HT_header(Header): bl_space_type = 'STATUSBAR' - def draw(self, context): + def draw(self, _context): layout = self.layout # input status diff --git a/scripts/startup/bl_ui/space_view3d_toolbar.py b/scripts/startup/bl_ui/space_view3d_toolbar.py index 3b1decdebc3..2464f037c66 100644 --- a/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -610,7 +610,7 @@ class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel): def get_mode_settings(self, context): return context.tool_settings.paint_mode - def draw_image_interpolation(self, **kwargs): + def draw_image_interpolation(self, **_kwargs): pass def draw_header(self, context): diff --git a/tools/check_blender_release/check_release.py b/tools/check_blender_release/check_release.py index d1a45c56d4e..cd4358c00fb 100755 --- a/tools/check_blender_release/check_release.py +++ b/tools/check_blender_release/check_release.py @@ -15,6 +15,9 @@ from check_utils import sliceCommandLineArguments def load_tests(loader, standard_tests, pattern): + # Unused. + del pattern + standard_tests.addTests(loader.loadTestsFromTestCase( check_module_enabled.UnitTesting)) standard_tests.addTests(loader.loadTestsFromTestCase( diff --git a/tools/check_source/check_cmake_consistency.py b/tools/check_source/check_cmake_consistency.py index 3b9fc741ea4..dce5c30fcb3 100755 --- a/tools/check_source/check_cmake_consistency.py +++ b/tools/check_source/check_cmake_consistency.py @@ -5,6 +5,10 @@ # Note: this code should be cleaned up / refactored. +__all__ = ( + "main", +) + import sys if sys.version_info.major < 3: print("\nPython3.x needed, found %s.\nAborting!\n" % @@ -51,7 +55,7 @@ for k, v in IGNORE_SOURCE_MISSING_FLAT: del IGNORE_SOURCE_MISSING_FLAT -def replace_line(f: str, i: int, text: str, keep_indent: bool = True) -> None: +def replace_line(f: str, i: int, text: str) -> None: file_handle = open(f, 'r') data = file_handle.readlines() file_handle.close() @@ -95,12 +99,15 @@ def is_c(filename: str) -> bool: return (ext in {".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl", ".metal", ".msl"}) -def is_c_any(filename: str) -> bool: - return is_c(filename) or is_c_header(filename) +# def is_c_any(filename: str) -> bool: +# return is_c(filename) or is_c_header(filename) def cmake_get_src(f: str) -> None: + # TODO: only partially implemented, needs work. + do_replace_text = False + sources_h = [] sources_c = [] @@ -272,8 +279,9 @@ def cmake_get_src(f: str) -> None: if new_path_rel != l: print("overly relative path:\n %s:%d\n %s\n %s" % (f, line_number, l, new_path_rel)) - # # Save time. just replace the line - # replace_line(f, line_number - 1, new_path_rel) + # Save time. just replace the line. + if do_replace_text: + replace_line(f, line_number - 1, new_path_rel) else: raise Exception("non existent include %s:%d -> %s" % (f, line_number, new_file)) diff --git a/tools/check_source/check_unused_defines.py b/tools/check_source/check_unused_defines.py index dce19f38dbc..9ddd5116da1 100755 --- a/tools/check_source/check_unused_defines.py +++ b/tools/check_source/check_unused_defines.py @@ -48,12 +48,13 @@ def remove_comments(string: str) -> str: regex = re.compile(pattern, re.MULTILINE | re.DOTALL) def _replacer(m: re.Match[str]) -> str: - # if the 2nd group (capturing comments) is not None, - # it means we have captured a non-quoted (real) comment string. + # If the 2nd group (capturing comments) is not None, + # It means we have captured a non-quoted (real) comment string. if m.group(2) is not None: - return "" # so we will return empty to remove the comment - else: # otherwise, we will return the 1st group - return m.group(1) # capture + # So we will return empty to remove the comment. + return "" + # Otherwise, we will return the 1st group. + return m.group(1) # capture return regex.sub(_replacer, string) @@ -69,8 +70,7 @@ def extract_terms(fn: str, data_src: str) -> None: for m in re_defines.finditer(data_src_nocomments): defines[m.group(1)] = fn - # Don't edit the file. - return None + # Returning None indicates the file is not edited. def main() -> int: diff --git a/tools/modules/blendfile.py b/tools/modules/blendfile.py index c1b854a7d21..1166a6c345c 100644 --- a/tools/modules/blendfile.py +++ b/tools/modules/blendfile.py @@ -101,7 +101,7 @@ class BlendFile: def __enter__(self): return self - def __exit__(self, type, value, traceback): + def __exit__(self, _type, _value, _traceback): self.close() def find_blocks_from_code(self, code): @@ -594,7 +594,7 @@ class BlendFileRaw: def __enter__(self): return self - def __exit__(self, type, value, traceback): + def __exit__(self, _type, _value, _traceback): self.close() def find_blocks_from_code(self, code): diff --git a/tools/utils/blender_theme_as_c.py b/tools/utils/blender_theme_as_c.py index 29a97258aca..16537f95881 100755 --- a/tools/utils/blender_theme_as_c.py +++ b/tools/utils/blender_theme_as_c.py @@ -174,7 +174,7 @@ def is_ignore_dna_name(name): return False -def write_member(fw, indent, b, theme, ls): +def write_member(fw, indent, _blend, _theme, ls): path_old = () for key, value in ls: diff --git a/tools/utils/gdb_struct_repr_c99.py b/tools/utils/gdb_struct_repr_c99.py index 41ab044350c..d93124d1f03 100644 --- a/tools/utils/gdb_struct_repr_c99.py +++ b/tools/utils/gdb_struct_repr_c99.py @@ -30,7 +30,7 @@ class PrintStructC99(gdb.Command): first_line = string.split('\n')[0] return first_line.split('=')[1][:-1].strip() - def invoke(self, arg, from_tty): + def invoke(self, arg, _from_tty): ret_ptype = gdb.execute('ptype {}'.format(arg), to_string=True) tname = self.extract_typename(ret_ptype) print('{} {} = {{'.format(tname, arg)) diff --git a/tools/utils/make_cursor_gui.py b/tools/utils/make_cursor_gui.py index a63a7c47bc2..8001e69dc14 100755 --- a/tools/utils/make_cursor_gui.py +++ b/tools/utils/make_cursor_gui.py @@ -292,7 +292,7 @@ class App: def main() -> int: root = Tk() - app = App(root) + _app = App(root) root.title("Cursor Maker") root.mainloop() diff --git a/tools/utils_maintenance/code_clean.py b/tools/utils_maintenance/code_clean.py index 9387dae9f4d..1ff237f6f90 100755 --- a/tools/utils_maintenance/code_clean.py +++ b/tools/utils_maintenance/code_clean.py @@ -449,7 +449,7 @@ class EditGenerator: def edit_list_from_file(_source: str, _data: str, _shared_edit_data: Any) -> list[Edit]: # The `__init_subclass__` function ensures this is always overridden. raise RuntimeError("This function must be overridden by it's subclass!") - return [] + # return [] @staticmethod def setup() -> Any: