Cleanup: quiet Python linter warnings
This commit is contained in:
@@ -229,7 +229,7 @@ class DNACatalogHTML:
|
|||||||
|
|
||||||
return structure_field
|
return structure_field
|
||||||
|
|
||||||
def indent(self, input, dent, startswith=''):
|
def indent(self, input, dent):
|
||||||
output = ''
|
output = ''
|
||||||
if dent < 0:
|
if dent < 0:
|
||||||
for line in input.split('\n'):
|
for line in input.split('\n'):
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def main():
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Operator
|
from bpy.types import Operator
|
||||||
|
|
||||||
def dummy_func(test):
|
def dummy_func(_test):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
kw_dummy = dict(fget=dummy_func, fset=dummy_func, fdel=dummy_func)
|
kw_dummy = dict(fget=dummy_func, fset=dummy_func, fdel=dummy_func)
|
||||||
|
|||||||
@@ -45,6 +45,6 @@ class RestrictBlend:
|
|||||||
_bpy.data = _data_restrict
|
_bpy.data = _data_restrict
|
||||||
_bpy.context = _context_restrict
|
_bpy.context = _context_restrict
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, _type, _value, _traceback):
|
||||||
_bpy.data = self.data
|
_bpy.data = self.data
|
||||||
_bpy.context = self.context
|
_bpy.context = self.context
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class _TempModuleOverride:
|
|||||||
self.module = sys.modules.get(self.module_name)
|
self.module = sys.modules.get(self.module_name)
|
||||||
sys.modules[self.module_name] = self.module_override
|
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:
|
if self.module is None:
|
||||||
# Account for removal of `module_override` (albeit unlikely).
|
# Account for removal of `module_override` (albeit unlikely).
|
||||||
sys.modules.pop(self.module_name, None)
|
sys.modules.pop(self.module_name, None)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ _node_categories = {}
|
|||||||
def register_node_categories(identifier, cat_list):
|
def register_node_categories(identifier, cat_list):
|
||||||
if identifier in _node_categories:
|
if identifier in _node_categories:
|
||||||
raise KeyError("Node categories list '{:s}' already registered".format(identifier))
|
raise KeyError("Node categories list '{:s}' already registered".format(identifier))
|
||||||
return
|
# return
|
||||||
|
|
||||||
# works as draw function for menus
|
# works as draw function for menus
|
||||||
def draw_node_item(self, context):
|
def draw_node_item(self, context):
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ def xml2rna(
|
|||||||
# print(elems)
|
# print(elems)
|
||||||
if len(elems) == 1:
|
if len(elems) == 1:
|
||||||
# sub node named by its type
|
# sub node named by its type
|
||||||
child_xml_real, = elems
|
child_xml_real = elems[0]
|
||||||
|
|
||||||
# print(child_xml_real, subvalue)
|
# print(child_xml_real, subvalue)
|
||||||
xml2rna_node(child_xml_real, subvalue)
|
xml2rna_node(child_xml_real, subvalue)
|
||||||
|
|||||||
@@ -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"}
|
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
|
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)
|
# print(options)
|
||||||
|
|
||||||
def handle_deg2rad(fcurve):
|
def handle_deg2rad(fcurve):
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class POSE_OT_selection_set_assign(_PoseModeOnlyMixin, Operator):
|
|||||||
bl_description = "Add selected bones to Selection Set"
|
bl_description = "Add selected bones to Selection Set"
|
||||||
bl_options = {'UNDO', 'REGISTER'}
|
bl_options = {'UNDO', 'REGISTER'}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, _event):
|
||||||
arm = context.object
|
arm = context.object
|
||||||
|
|
||||||
if not (arm.active_selection_set < len(arm.selection_sets)):
|
if not (arm.active_selection_set < len(arm.selection_sets)):
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ def align_uv_rotation_island(bm, uv_layer, faces, method, axis, aspect_y):
|
|||||||
return True
|
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
|
import bpy_extras.bmesh_utils
|
||||||
|
|
||||||
uv_layer = bm.loops.layers.uv.active
|
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:
|
for ob in ob_list:
|
||||||
bm = bmesh.from_edit_mesh(ob.data)
|
bm = bmesh.from_edit_mesh(ob.data)
|
||||||
if bm.loops.layers.uv:
|
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)
|
bmesh.update_edit_mesh(ob.data)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ class UI_MT_list_item_context_menu(bpy.types.Menu):
|
|||||||
bl_label = "List Item"
|
bl_label = "List Item"
|
||||||
bl_idname = "UI_MT_list_item_context_menu"
|
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
|
# Dummy function. This type is just for scripts to append their own
|
||||||
# context menu items.
|
# context menu items.
|
||||||
pass
|
pass
|
||||||
@@ -282,7 +282,7 @@ class UI_MT_button_context_menu(bpy.types.Menu):
|
|||||||
bl_label = "List Item"
|
bl_label = "List Item"
|
||||||
bl_idname = "UI_MT_button_context_menu"
|
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.
|
# Draw menu entries created with the legacy `WM_MT_button_context` class.
|
||||||
# This is deprecated, and support will be removed in a future release.
|
# This is deprecated, and support will be removed in a future release.
|
||||||
if hasattr(bpy.types, "WM_MT_button_context"):
|
if hasattr(bpy.types, "WM_MT_button_context"):
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from bpy.types import Menu
|
|||||||
class ANIM_MT_keyframe_insert_pie(Menu):
|
class ANIM_MT_keyframe_insert_pie(Menu):
|
||||||
bl_label = "Keyframe Insert Pie"
|
bl_label = "Keyframe Insert Pie"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, _context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
pie = layout.menu_pie()
|
pie = layout.menu_pie()
|
||||||
|
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ class POSE_PT_selection_sets(Panel):
|
|||||||
|
|
||||||
|
|
||||||
class POSE_UL_selection_set(UIList):
|
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 = layout.row()
|
||||||
row.prop(item, "name", text="", emboss=False)
|
row.prop(item, "name", text="", emboss=False)
|
||||||
if self.layout_type in ('DEFAULT', 'COMPACT'):
|
if self.layout_type in ('DEFAULT', 'COMPACT'):
|
||||||
@@ -389,7 +389,7 @@ class POSE_UL_selection_set(UIList):
|
|||||||
class POSE_MT_selection_set_create(Menu):
|
class POSE_MT_selection_set_create(Menu):
|
||||||
bl_label = "Choose Selection Set"
|
bl_label = "Choose Selection Set"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, _context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.operator("pose.selection_set_add_and_assign",
|
layout.operator("pose.selection_set_add_and_assign",
|
||||||
text="New Selection Set")
|
text="New Selection Set")
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ class AddModifierMenu(Operator):
|
|||||||
return False
|
return False
|
||||||
return space and space.type == 'PROPERTIES' and space.context == 'MODIFIER'
|
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")
|
return bpy.ops.wm.call_menu(name="OBJECT_MT_modifier_add")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ class GREASE_PENCIL_MT_draw_delete(Menu):
|
|||||||
class GREASE_PENCIL_MT_stroke_simplify(Menu):
|
class GREASE_PENCIL_MT_stroke_simplify(Menu):
|
||||||
bl_label = "Simplify Stroke"
|
bl_label = "Simplify Stroke"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, _context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.operator("grease_pencil.stroke_simplify", text="Fixed").mode = 'FIXED'
|
layout.operator("grease_pencil.stroke_simplify", text="Fixed").mode = 'FIXED'
|
||||||
layout.operator("grease_pencil.stroke_simplify", text="Adaptive").mode = 'ADAPTIVE'
|
layout.operator("grease_pencil.stroke_simplify", text="Adaptive").mode = 'ADAPTIVE'
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class WORKSPACE_UL_addons_items(UIList):
|
|||||||
indices = self._sort_addons_by_category_name(addons)
|
indices = self._sort_addons_by_category_name(addons)
|
||||||
return flags, indices
|
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 = layout.row()
|
||||||
row.active = context.workspace.use_filter_by_owner
|
row.active = context.workspace.use_filter_by_owner
|
||||||
row.emboss = 'NONE'
|
row.emboss = 'NONE'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from bpy.types import Header
|
|||||||
class STATUSBAR_HT_header(Header):
|
class STATUSBAR_HT_header(Header):
|
||||||
bl_space_type = 'STATUSBAR'
|
bl_space_type = 'STATUSBAR'
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, _context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
# input status
|
# input status
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel):
|
|||||||
def get_mode_settings(self, context):
|
def get_mode_settings(self, context):
|
||||||
return context.tool_settings.paint_mode
|
return context.tool_settings.paint_mode
|
||||||
|
|
||||||
def draw_image_interpolation(self, **kwargs):
|
def draw_image_interpolation(self, **_kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ from check_utils import sliceCommandLineArguments
|
|||||||
|
|
||||||
|
|
||||||
def load_tests(loader, standard_tests, pattern):
|
def load_tests(loader, standard_tests, pattern):
|
||||||
|
# Unused.
|
||||||
|
del pattern
|
||||||
|
|
||||||
standard_tests.addTests(loader.loadTestsFromTestCase(
|
standard_tests.addTests(loader.loadTestsFromTestCase(
|
||||||
check_module_enabled.UnitTesting))
|
check_module_enabled.UnitTesting))
|
||||||
standard_tests.addTests(loader.loadTestsFromTestCase(
|
standard_tests.addTests(loader.loadTestsFromTestCase(
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
# Note: this code should be cleaned up / refactored.
|
# Note: this code should be cleaned up / refactored.
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
"main",
|
||||||
|
)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.version_info.major < 3:
|
if sys.version_info.major < 3:
|
||||||
print("\nPython3.x needed, found %s.\nAborting!\n" %
|
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
|
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')
|
file_handle = open(f, 'r')
|
||||||
data = file_handle.readlines()
|
data = file_handle.readlines()
|
||||||
file_handle.close()
|
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"})
|
return (ext in {".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl", ".metal", ".msl"})
|
||||||
|
|
||||||
|
|
||||||
def is_c_any(filename: str) -> bool:
|
# def is_c_any(filename: str) -> bool:
|
||||||
return is_c(filename) or is_c_header(filename)
|
# return is_c(filename) or is_c_header(filename)
|
||||||
|
|
||||||
|
|
||||||
def cmake_get_src(f: str) -> None:
|
def cmake_get_src(f: str) -> None:
|
||||||
|
|
||||||
|
# TODO: only partially implemented, needs work.
|
||||||
|
do_replace_text = False
|
||||||
|
|
||||||
sources_h = []
|
sources_h = []
|
||||||
sources_c = []
|
sources_c = []
|
||||||
|
|
||||||
@@ -272,8 +279,9 @@ def cmake_get_src(f: str) -> None:
|
|||||||
if new_path_rel != l:
|
if new_path_rel != l:
|
||||||
print("overly relative path:\n %s:%d\n %s\n %s" % (f, line_number, l, new_path_rel))
|
print("overly relative path:\n %s:%d\n %s\n %s" % (f, line_number, l, new_path_rel))
|
||||||
|
|
||||||
# # Save time. just replace the line
|
# Save time. just replace the line.
|
||||||
# replace_line(f, line_number - 1, new_path_rel)
|
if do_replace_text:
|
||||||
|
replace_line(f, line_number - 1, new_path_rel)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception("non existent include %s:%d -> %s" % (f, line_number, new_file))
|
raise Exception("non existent include %s:%d -> %s" % (f, line_number, new_file))
|
||||||
|
|||||||
@@ -48,12 +48,13 @@ def remove_comments(string: str) -> str:
|
|||||||
regex = re.compile(pattern, re.MULTILINE | re.DOTALL)
|
regex = re.compile(pattern, re.MULTILINE | re.DOTALL)
|
||||||
|
|
||||||
def _replacer(m: re.Match[str]) -> str:
|
def _replacer(m: re.Match[str]) -> str:
|
||||||
# if the 2nd group (capturing comments) is not None,
|
# If the 2nd group (capturing comments) is not None,
|
||||||
# it means we have captured a non-quoted (real) comment string.
|
# It means we have captured a non-quoted (real) comment string.
|
||||||
if m.group(2) is not None:
|
if m.group(2) is not None:
|
||||||
return "" # so we will return empty to remove the comment
|
# So we will return empty to remove the comment.
|
||||||
else: # otherwise, we will return the 1st group
|
return ""
|
||||||
return m.group(1) # capture
|
# Otherwise, we will return the 1st group.
|
||||||
|
return m.group(1) # capture
|
||||||
return regex.sub(_replacer, string)
|
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):
|
for m in re_defines.finditer(data_src_nocomments):
|
||||||
defines[m.group(1)] = fn
|
defines[m.group(1)] = fn
|
||||||
|
|
||||||
# Don't edit the file.
|
# Returning None indicates the file is not edited.
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class BlendFile:
|
|||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, _type, _value, _traceback):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def find_blocks_from_code(self, code):
|
def find_blocks_from_code(self, code):
|
||||||
@@ -594,7 +594,7 @@ class BlendFileRaw:
|
|||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, _type, _value, _traceback):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def find_blocks_from_code(self, code):
|
def find_blocks_from_code(self, code):
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ def is_ignore_dna_name(name):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def write_member(fw, indent, b, theme, ls):
|
def write_member(fw, indent, _blend, _theme, ls):
|
||||||
path_old = ()
|
path_old = ()
|
||||||
|
|
||||||
for key, value in ls:
|
for key, value in ls:
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class PrintStructC99(gdb.Command):
|
|||||||
first_line = string.split('\n')[0]
|
first_line = string.split('\n')[0]
|
||||||
return first_line.split('=')[1][:-1].strip()
|
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)
|
ret_ptype = gdb.execute('ptype {}'.format(arg), to_string=True)
|
||||||
tname = self.extract_typename(ret_ptype)
|
tname = self.extract_typename(ret_ptype)
|
||||||
print('{} {} = {{'.format(tname, arg))
|
print('{} {} = {{'.format(tname, arg))
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ class App:
|
|||||||
def main() -> int:
|
def main() -> int:
|
||||||
root = Tk()
|
root = Tk()
|
||||||
|
|
||||||
app = App(root)
|
_app = App(root)
|
||||||
root.title("Cursor Maker")
|
root.title("Cursor Maker")
|
||||||
|
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ class EditGenerator:
|
|||||||
def edit_list_from_file(_source: str, _data: str, _shared_edit_data: Any) -> list[Edit]:
|
def edit_list_from_file(_source: str, _data: str, _shared_edit_data: Any) -> list[Edit]:
|
||||||
# The `__init_subclass__` function ensures this is always overridden.
|
# The `__init_subclass__` function ensures this is always overridden.
|
||||||
raise RuntimeError("This function must be overridden by it's subclass!")
|
raise RuntimeError("This function must be overridden by it's subclass!")
|
||||||
return []
|
# return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup() -> Any:
|
def setup() -> Any:
|
||||||
|
|||||||
Reference in New Issue
Block a user