[Bf-blender-cvs] [39c341bf4ab] master: Cleanup: remove redundant braces from assert & raise

Campbell Barton noreply at git.blender.org
Wed Sep 14 08:21:11 CEST 2022


Commit: 39c341bf4ab9582edc26227447634cae2004baa6
Author: Campbell Barton
Date:   Wed Sep 14 16:18:59 2022 +1000
Branches: master
https://developer.blender.org/rB39c341bf4ab9582edc26227447634cae2004baa6

Cleanup: remove redundant braces from assert & raise

autopep8 v1.7 added a space after assert & raise,
remove the braces as they aren't needed.

===================================================================

M	doc/manpage/blender.1.py
M	doc/python_api/rst_from_bmesh_opdefines.py
M	doc/python_api/sphinx_changelog_gen.py
M	doc/python_api/sphinx_doc_gen.py
M	release/datafiles/blender_icons_geom.py
M	release/datafiles/ctodata.py
M	release/scripts/freestyle/modules/freestyle/functions.py
M	release/scripts/modules/bl_app_override/__init__.py
M	release/scripts/modules/bl_app_override/helpers.py
M	release/scripts/modules/bl_console_utils/autocomplete/complete_import.py
M	release/scripts/modules/bl_console_utils/autocomplete/complete_namespace.py
M	release/scripts/modules/bl_i18n_utils/settings.py
M	release/scripts/modules/bl_i18n_utils/utils.py
M	release/scripts/modules/bl_keymap_utils/io.py
M	release/scripts/modules/bpy_extras/io_utils.py
M	release/scripts/modules/bpy_extras/node_shader_utils.py
M	release/scripts/modules/bpy_extras/wm_utils/progress_report.py
M	release/scripts/modules/rna_prop_ui.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_operators/uvcalc_follow_active.py
M	release/scripts/startup/bl_operators/uvcalc_lightmap.py
M	release/scripts/startup/bl_operators/wm.py
M	release/scripts/startup/bl_ui/space_toolsystem_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/datatoc/datatoc_icon.py
M	tests/python/bl_blendfile_io.py
M	tests/python/bl_blendfile_liblink.py
M	tests/python/bl_blendfile_library_overrides.py
M	tests/python/bl_keymap_validate.py
M	tests/python/bl_load_addons.py
M	tests/python/bl_load_py_modules.py
M	tests/python/bl_mesh_modifiers.py
M	tests/python/bl_pyapi_idprop.py
M	tests/python/bl_rna_manual_reference.py
M	tests/python/bl_run_operators_event_simulate.py

===================================================================

diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py
index 7d35dc0abb1..49dae35e0c5 100755
--- a/doc/manpage/blender.1.py
+++ b/doc/manpage/blender.1.py
@@ -139,7 +139,7 @@ https://www.blender.org''')
 
                 l = lines.pop(0)
                 if l:
-                    assert(l.startswith('\t'))
+                    assert l.startswith('\t')
                     l = l[1:]  # Remove first white-space (tab).
 
                 fh.write('%s\n' % man_format(l))
diff --git a/doc/python_api/rst_from_bmesh_opdefines.py b/doc/python_api/rst_from_bmesh_opdefines.py
index 3d8ff1e6248..0614538964d 100644
--- a/doc/python_api/rst_from_bmesh_opdefines.py
+++ b/doc/python_api/rst_from_bmesh_opdefines.py
@@ -241,9 +241,9 @@ def main():
         comment_washed = []
         comment = [] if comment is None else comment
         for i, l in enumerate(comment):
-            assert((l.strip() == "") or
-                   (l in {"/*", " *"}) or
-                   (l.startswith(("/* ", " * "))))
+            assert ((l.strip() == "") or
+                    (l in {"/*", " *"}) or
+                    (l.startswith(("/* ", " * "))))
 
             l = l[3:]
             if i == 0 and not l.strip():
@@ -270,7 +270,7 @@ def main():
                     tp_sub = None
                 else:
                     print(arg)
-                    assert(0)
+                    assert 0
 
                 tp_str = ""
 
@@ -315,7 +315,7 @@ def main():
                         tp_str += " or any sequence of 3 floats"
                 elif tp == BMO_OP_SLOT_PTR:
                     tp_str = "dict"
-                    assert(tp_sub is not None)
+                    assert tp_sub is not None
                     if tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_BMESH:
                         tp_str = ":class:`bmesh.types.BMesh`"
                     elif tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_SCENE:
@@ -330,10 +330,10 @@ def main():
                         tp_str = ":class:`bpy.types.bpy_struct`"
                     else:
                         print("Can't find", vars_dict_reverse[tp_sub])
-                        assert(0)
+                        assert 0
 
                 elif tp == BMO_OP_SLOT_ELEMENT_BUF:
-                    assert(tp_sub is not None)
+                    assert tp_sub is not None
 
                     ls = []
                     if tp_sub & BM_VERT:
@@ -342,7 +342,7 @@ def main():
                         ls.append(":class:`bmesh.types.BMEdge`")
                     if tp_sub & BM_FACE:
                         ls.append(":class:`bmesh.types.BMFace`")
-                    assert(ls)  # must be at least one
+                    assert ls  # Must be at least one.
 
                     if tp_sub & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE:
                         tp_str = "/".join(ls)
@@ -367,10 +367,10 @@ def main():
                             tp_str += "unknown internal data, not compatible with python"
                         else:
                             print("Can't find", vars_dict_reverse[tp_sub])
-                            assert(0)
+                            assert 0
                 else:
                     print("Can't find", vars_dict_reverse[tp])
-                    assert(0)
+                    assert 0
 
                 args_wash.append((name, tp_str, comment))
             return args_wash
@@ -394,7 +394,7 @@ def main():
             fw("   :return:\n\n")
 
             for (name, tp, comment) in args_out_wash:
-                assert(name.endswith(".out"))
+                assert name.endswith(".out")
                 name = name[:-4]
                 fw("      - ``%s``: %s\n\n" % (name, comment))
                 fw("        **type** %s\n" % tp)
diff --git a/doc/python_api/sphinx_changelog_gen.py b/doc/python_api/sphinx_changelog_gen.py
index 4c9f7232a74..e2bbf7c3acd 100644
--- a/doc/python_api/sphinx_changelog_gen.py
+++ b/doc/python_api/sphinx_changelog_gen.py
@@ -101,7 +101,7 @@ def api_dump(args):
 
     version, version_key = api_version()
     if version is None:
-        raise(ValueError("API dumps can only be generated from within Blender."))
+        raise ValueError("API dumps can only be generated from within Blender.")
 
     dump = {}
     dump_module = dump["bpy.types"] = {}
@@ -250,7 +250,7 @@ def api_changelog(args):
 
     version, version_key = api_version()
     if version is None and (filepath_in_from is None or filepath_in_to is None):
-        raise(ValueError("API dumps files must be given when ran outside of Blender."))
+        raise ValueError("API dumps files must be given when ran outside of Blender.")
 
     with open(indexpath, 'r', encoding='utf-8') as file_handle:
         index = json.load(file_handle)
@@ -258,17 +258,21 @@ def api_changelog(args):
     if filepath_in_to is None:
         filepath_in_to = index.get(version_key, None)
     if filepath_in_to is None:
-        raise(ValueError("Cannot find API dump file for Blender version " + str(version) + " in index file."))
+        raise ValueError("Cannot find API dump file for Blender version " + str(version) + " in index file.")
 
     print("Found to file: %r" % filepath_in_to)
 
     if filepath_in_from is None:
         version_from, version_from_key = api_version_previous_in_index(index, version)
         if version_from is None:
-            raise(ValueError("No previous version of Blender could be found in the index."))
+            raise ValueError("No previous version of Blender could be found in the index.")
         filepath_in_from = index.get(version_from_key, None)
     if filepath_in_from is None:
-        raise(ValueError("Cannot find API dump file for previous Blender version " + str(version_from) + " in index file."))
+        raise ValueError(
+            "Cannot find API dump file for previous Blender version " +
+            str(version_from) +
+            " in index file."
+        )
 
     print("Found from file: %r" % filepath_in_from)
 
@@ -277,7 +281,7 @@ def api_changelog(args):
 
     with open(os.path.join(rootpath, filepath_in_to), 'r', encoding='utf-8') as file_handle:
         dump_version, dict_to = json.load(file_handle)
-        assert(tuple(dump_version) == version)
+        assert tuple(dump_version) == version
 
     api_changes = []
 
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index e07afe44545..0887e9e74d8 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1477,7 +1477,7 @@ def pyrna2sphinx(basepath):
 
         struct_module_name = struct.module_name
         if USE_ONLY_BUILTIN_RNA_TYPES:
-            assert (struct_module_name == "bpy.types")
+            assert struct_module_name == "bpy.types"
         filepath = os.path.join(basepath, "%s.%s.rst" % (struct_module_name, struct.identifier))
         file = open(filepath, "w", encoding="utf-8")
         fw = file.write
diff --git a/release/datafiles/blender_icons_geom.py b/release/datafiles/blender_icons_geom.py
index b95baf3419e..878cc4b46f6 100644
--- a/release/datafiles/blender_icons_geom.py
+++ b/release/datafiles/blender_icons_geom.py
@@ -72,7 +72,7 @@ class TriMesh:
     @staticmethod
     def _tri_copy_from_object(ob):
         import bmesh
-        assert(ob.type in OBJECTS_TYPES_MESH_COMPATIBLE)
+        assert ob.type in OBJECTS_TYPES_MESH_COMPATIBLE
         bm = bmesh.new()
         bm.from_mesh(ob.to_mesh())
         bmesh.ops.triangulate(bm, faces=bm.faces)
@@ -143,7 +143,7 @@ def mesh_data_lists_from_mesh(me, material_colors):
         i1 = 1
 
         # we only write tris now
-        assert(len(loops_poly) == 3)
+        assert len(loops_poly) == 3
 
         for i2 in range(2, l_len):
             l0 = loops_poly[i0]
@@ -217,7 +217,7 @@ def mesh_data_lists_from_objects(ob_parent, ob_children):
 def write_mesh_to_py(fh, ob, ob_children):
 
     def float_as_byte(f, axis_range):
-        assert(axis_range <= 255)
+        assert axis_range <= 255
         # -1..1 -> 0..255
         f = (f + 1.0) * 0.5
         f = round(f * axis_range)
@@ -238,7 +238,7 @@ def write_mesh_to_py(fh, ob, ob_children):
     if 0:
         # make as large as we can, keeping alignment
         def size_scale_up(size):
-            assert(size != 0)
+            assert size != 0
             while size * 2 <= 255:
                 size *= 2
             return size
diff --git a/release/datafiles/ctodata.py b/release/datafiles/ctodata.py
index b6420d5c9a2..6c5afdb1b5b 100755
--- a/release/datafiles/ctodata.py
+++ b/release/datafiles/ctodata.py
@@ -31,7 +31,7 @@ data = [int(v) for v in data]
 if strip_byte:
     # String data gets trailing byte.
     last = data.pop()
-    assert(last == 0)
+    assert last == 0
 
 data = bytes(data)
 
diff --git a/release/scripts/freestyle/modules/freestyle/functions.py b/release/scripts/freestyle/modules/freestyle/functions.py
index 4a4a2f036e1..326e072d34a 100644
--- a/release/scripts/freestyle/modules/freestyle/functions.py
+++ b/release/scripts/freestyle/modules/freestyle/functions.py
@@ -198,7 +198,7 @@ class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble):
 class pyCurvilinearLengthF0D(UnaryFunction0DDouble):
     def __call__(self, inter):
         cp = inter.object
-        assert(isinstance(cp, CurvePoint))
+        assert isinstance(cp, CurvePoint)
         return cp.t2d
 
 
diff --git a/release/scripts/modules/bl_app_override/__init__.py b/release/scripts/modules/bl_app_override/__init__.py
index 4d6194e71cd..1408cf3594f 100644
--- a/release/scripts/modules/bl_app_override/__init__.py
+++ b/release/scripts/modules/bl_app_override/__init__.py
@@ -74,7 +74,7 @@ def ui_draw_filter_register(
                         if ui_test is None:
                             UILayout.__getattribute__(self, "label")(text="")
                         else:
-                            assert(ui_test is True)
+                            assert ui_test is True
                         # may need to be set
                         ret = OperatorProperties_Fake()
                     return ret
@@ -95,7 +95,7 @@ def ui_draw_filter_register(
                         if ui_test is None:
                             UILayout.__getattribute__

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list