diff --git a/.flake8 b/.flake8 index cb152b5a..dbb2f353 100644 --- a/.flake8 +++ b/.flake8 @@ -2,10 +2,11 @@ max-line-length = 120 ignore = E203, E501, W503 # Incompatible with black -exclude = - .git - .history - .venv - .vscode - __pycache__ - gitlab/blender \ No newline at end of file +per-file-ignores = + mixer/bl_preferences.py:F821,F722 + mixer/bl_operators.py:F821,F722 + mixer/bl_properties.py:F821,F722 + mixer/blender_data/debug_addon.py:F821 + tests/python_server.py:F821,F722 +# F821 produces "'undefined name 'XXX'" when we write things like 'member_variable: bpy.props.StringProperty(subtype="XXX")' +# F722 produces "syntax error in forward annotation 'XXX'" when we write things like 'member_variable: bpy.props.IntProperty(name="XXX")' \ No newline at end of file diff --git a/mixer/bl_panels.py b/mixer/bl_panels.py index 81c692ef..20d7ad12 100644 --- a/mixer/bl_panels.py +++ b/mixer/bl_panels.py @@ -265,7 +265,7 @@ def is_user_displayed(user: UserItem): user_layout.separator(factor=0.2) if collapsable_panel( - layout, mixer_props, "display_snapping_options", alert=True, text=f"Sync Options - Not implemented yet" + layout, mixer_props, "display_snapping_options", alert=True, text="Sync Options - Not implemented yet" ): box = layout.box().column() if share_data.client.current_room is None: @@ -317,7 +317,7 @@ def draw(self, context): text=f"Room: {share_data.client.current_room}{(' (experimental sync)' if mixer_prefs.experimental_sync else '')}" ) split.label(text=f"Join: {get_mixer_props().joining_percentage * 100:.2f} %") - split.operator(bl_operators.LeaveRoomOperator.bl_idname, text=f"Leave Room") + split.operator(bl_operators.LeaveRoomOperator.bl_idname, text="Leave Room") self.draw_rooms(layout) self.draw_users(layout) diff --git a/mixer/bl_properties.py b/mixer/bl_properties.py index e7b2dca8..a773371a 100644 --- a/mixer/bl_properties.py +++ b/mixer/bl_properties.py @@ -212,7 +212,7 @@ def get_snap_view_area(self, context): display_advanced_room_control: bpy.props.BoolProperty(default=False) upload_room_name: bpy.props.StringProperty(default=f"{getuser()}_uploaded_room", name="Upload Room Name") - upload_room_filepath: bpy.props.StringProperty(default=f"", subtype="FILE_PATH", name="Upload Room File") + upload_room_filepath: bpy.props.StringProperty(default="", subtype="FILE_PATH", name="Upload Room File") joining_percentage: bpy.props.FloatProperty(default=0, name="Joining Percentage") diff --git a/mixer/blender_client/collection.py b/mixer/blender_client/collection.py index 48306227..8215f199 100644 --- a/mixer/blender_client/collection.py +++ b/mixer/blender_client/collection.py @@ -65,7 +65,7 @@ def build_collection_removed(data): del share_data.blender_collections[name_full] bpy.data.collections.remove(collection) except Exception as e: - logger.info(f"build_remove_collection_from_scene: exception during unlink... ") + logger.info("build_remove_collection_from_scene: exception during unlink... ") logger.info(f"... {e} ") @@ -90,12 +90,12 @@ def build_collection_to_collection(data): if share_data.use_experimental_sync(): # Added by the Blender Protocol logger.info(f"build_collection_to_collection(): parent {parent_name}, child {child_name}...") - logger.info(f"... Exception during parent.children.link() ...") - logger.info(f"... Safe in experimental_sync ...") + logger.info("... Exception during parent.children.link() ...") + logger.info("... Safe in experimental_sync ...") logger.info(f"... {e}") else: logger.warning(f"build_collection_to_collection(): parent {parent_name}, child {child_name}...") - logger.warning(f"... Exception during parent.children.link() ...") + logger.warning("... Exception during parent.children.link() ...") logger.warning(f"... {e}") @@ -154,7 +154,7 @@ def build_remove_object_from_collection(data): try: collection.objects.unlink(object_) except Exception as e: - logger.info(f"build_remove_object_from_collection: exception during unlink... ") + logger.info("build_remove_object_from_collection: exception during unlink... ") logger.info(f"... {e} ") diff --git a/mixer/blender_client/data.py b/mixer/blender_client/data.py index 0e5b2143..136221b4 100644 --- a/mixer/blender_client/data.py +++ b/mixer/blender_client/data.py @@ -68,7 +68,7 @@ def log_exception(when: str): logger.error(buffer[0:200]) logger.error("...") logger.error(buffer[-200:0]) - logger.error(f"ignored") + logger.error("ignored") if not share_data.use_experimental_sync(): return diff --git a/mixer/blender_client/mesh.py b/mixer/blender_client/mesh.py index e27003b7..8270e89a 100644 --- a/mixer/blender_client/mesh.py +++ b/mixer/blender_client/mesh.py @@ -513,8 +513,8 @@ def decode_baked_mesh(obj, data, index): # hack ! Since bmesh cannot be used to set custom normals normals2 = [] - for l in me.loops: - normals2.append(normals[l.vertex_index]) + for loop in me.loops: + normals2.append(normals[loop.vertex_index]) me.normals_split_custom_set(normals2) me.use_auto_smooth = True diff --git a/mixer/blender_client/scene.py b/mixer/blender_client/scene.py index bc8e6ec9..2bb0eb6b 100644 --- a/mixer/blender_client/scene.py +++ b/mixer/blender_client/scene.py @@ -107,8 +107,8 @@ def build_collection_to_scene(data): if share_data.use_experimental_sync(): # Added by the Blender Protocol logger.info(f"build_collection_to_scene(): scene {scene_name}, collection {collection_name}...") - logger.info(f"... Exception during scene.collection.children.link() ...") - logger.info(f"... Safe in experimental_sync ...") + logger.info("... Exception during scene.collection.children.link() ...") + logger.info("... Safe in experimental_sync ...") logger.info(f"... {e}") else: raise @@ -133,7 +133,7 @@ def build_remove_collection_from_scene(data): try: scene.collection.children.unlink(collection) except Exception as e: - logger.info(f"build_remove_collection_from_scene: exception during unlink... ") + logger.info("build_remove_collection_from_scene: exception during unlink... ") logger.info(f"... {e} ") @@ -179,5 +179,5 @@ def build_remove_object_from_scene(data): try: scene.collection.objects.unlink(object_) except Exception as e: - logger.info(f"build_remove_object_from_scene: exception during unlink... ") + logger.info("build_remove_object_from_scene: exception during unlink... ") logger.info(f"... {e} ") diff --git a/mixer/blender_data/diff.py b/mixer/blender_data/diff.py index 8e66a051..d83f29a8 100644 --- a/mixer/blender_data/diff.py +++ b/mixer/blender_data/diff.py @@ -80,7 +80,7 @@ def diff(self, proxy: BpyPropDataCollectionProxy, collection_name: str, context: # duplicate uuid, from an object duplication original_item = blender_items[uuid] logger.info(f"Duplicate uuid {uuid} for {original_item[1]} and {item.name}...") - logger.info(f"... assuming object was duplicated. Resetting (not an error)") + logger.info("... assuming object was duplicated. Resetting (not an error)") # reset the uuid, ensure will regenerate item.mixer_uuid = "" diff --git a/mixer/blender_data/proxy.py b/mixer/blender_data/proxy.py index 2fa4a7ee..4819b3b6 100644 --- a/mixer/blender_data/proxy.py +++ b/mixer/blender_data/proxy.py @@ -178,7 +178,7 @@ def read_attribute(attr: Any, attr_property: T.Property, visit_state: VisitState # if we arrive here, we have cyclical data references that should be excluded in filter.py if not debug_context.limit_notified: debug_context.limit_notified = True - logger.error(f"Maximum property depth exceeded. Deeper properties ignored. Path :") + logger.error("Maximum property depth exceeded. Deeper properties ignored. Path :") logger.error(debug_context.property_fullpath()) return @@ -344,7 +344,7 @@ def save(self, bl_instance: any, key: Union[int, str], visit_state: VisitState): if target is None: if isinstance(bl_instance, T.bpy_prop_collection): logger.warning(f"Cannot write to '{bl_instance}', attribute '{key}' because it does not exist.") - logger.warning(f"Note: Not implemented write to dict") + logger.warning("Note: Not implemented write to dict") else: # Don't log this because it produces too many log messages when participants have plugins # f"Note: May be due to a plugin used by the sender and not on this Blender" @@ -1548,7 +1548,7 @@ def write_attribute(bl_instance, key: Union[str, int], value: Any, visit_state: """ if bl_instance is None: - logger.warning(f"unexpected write None attribute") + logger.warning("unexpected write None attribute") return try: diff --git a/mixer/broadcaster/apps/cli.py b/mixer/broadcaster/apps/cli.py index d31d4768..ff95b534 100644 --- a/mixer/broadcaster/apps/cli.py +++ b/mixer/broadcaster/apps/cli.py @@ -150,7 +150,7 @@ def interactive_loop(args): if client is None or not client.is_connected(): client = CliClient(args) else: - print(f"Error : already connected. Use disconnect first") + print("Error : already connected. Use disconnect first") elif command == "exit": done = True elif command == "help": diff --git a/mixer/broadcaster/apps/server.py b/mixer/broadcaster/apps/server.py index 1b0f23a7..a211a1d7 100644 --- a/mixer/broadcaster/apps/server.py +++ b/mixer/broadcaster/apps/server.py @@ -76,7 +76,7 @@ def _join_room(command: common.Command): def _leave_room(command: common.Command): if self.room is None: - _send_error(f"Received leave_room but no room is joined") + _send_error("Received leave_room but no room is joined") return _ = command.data.decode() # todo remove room_name from protocol self._server.leave_room(self) diff --git a/tests/blender/test_blenddata_ids.py b/tests/blender/test_blenddata_ids.py index 649814d1..81198a1b 100644 --- a/tests/blender/test_blenddata_ids.py +++ b/tests/blender/test_blenddata_ids.py @@ -4,7 +4,7 @@ class TestMetaBall(TestGenericJoinBefore): def test_bpy_data_new(self): - create_metaball = f""" + create_metaball = """ import bpy name = "mb1" mb = bpy.data.metaballs.new(name) @@ -21,7 +21,7 @@ def test_bpy_data_new(self): self.end_test() def test_bpy_ops_object_add(self): - action = f""" + action = """ import bpy bpy.ops.object.metaball_add(type='PLANE', location=(1.0, 1.0, 1.0)) o1 = bpy.context.active_object @@ -32,14 +32,14 @@ def test_bpy_ops_object_add(self): self.end_test() def test_add_remove(self): - action = f""" + action = """ import bpy bpy.ops.object.metaball_add(type='CAPSULE', location=(0.0, 0.0, 0.0)) bpy.ops.object.metaball_add(type='PLANE', location=(1.0, 1.0, 1.0)) bpy.ops.object.metaball_add(type='BALL', location=(-1.0, -1.0, -1.0)) """ self.send_string(action) - action = f""" + action = """ name = "Mball.001" import bpy D=bpy.data @@ -53,7 +53,7 @@ def test_add_remove(self): class TestLight(TestGenericJoinBefore): def test_bpy_ops_object_add(self): - action = f""" + action = """ import bpy bpy.ops.object.light_add(type='POINT', location=(0.0, 0.0, 0.0)) bpy.ops.object.light_add(type='SUN', location=(2.0, 0.0, 0.0)) @@ -63,12 +63,12 @@ def test_bpy_ops_object_add(self): self.end_test() def test_change_area_attrs(self): - action = f""" + action = """ import bpy bpy.ops.object.light_add(type='AREA', location=(4.0, 0.0, 0.0)) """ self.send_string(action) - action = f""" + action = """ import bpy D=bpy.data area = D.lights["Area"] @@ -79,12 +79,12 @@ def test_change_area_attrs(self): self.end_test() def test_morph_light(self): - action = f""" + action = """ import bpy bpy.ops.object.light_add(type='AREA', location=(4.0, 0.0, 0.0)) """ self.send_string(action) - action = f""" + action = """ import bpy D=bpy.data light = D.lights["Area"] diff --git a/tests/blender/test_proxy.py b/tests/blender/test_proxy.py index c4facfe4..fb8c98c9 100644 --- a/tests/blender/test_proxy.py +++ b/tests/blender/test_proxy.py @@ -4,7 +4,7 @@ class TestBpyProxy(TestGenericJoinBefore): def force_sync(self): - action = f""" + action = """ import bpy bpy.data.scenes[0].use_gravity = not bpy.data.scenes[0].use_gravity """ @@ -17,14 +17,14 @@ def test_just_join(self): def test_duplicate_uuid_metaball(self): # with metaballs the effect of duplicate uuids is visible as they are not # handled by the VRtist protocol - action = f""" + action = """ import bpy bpy.ops.object.metaball_add(type='BALL', location=(0,0,0)) obj = bpy.context.active_object """ self.send_string(action) - action = f""" + action = """ import bpy D = bpy.data bpy.ops.object.duplicate() @@ -39,7 +39,7 @@ def test_duplicate_uuid_metaball(self): class TestBpyPropStructCollectionProxy(TestGenericJoinBefore): def test_light_falloff_curve_add_point(self): - action = f""" + action = """ import bpy bpy.ops.object.light_add(type='POINT') """ @@ -48,7 +48,7 @@ def test_light_falloff_curve_add_point(self): # HACK it seems that we do not receive the depsgraph update # for light.falloff_curve.curves[0].points so add a Light member update - action = f""" + action = """ import bpy light = bpy.data.lights['Point'] light.falloff_curve.curves[0].points.new(0.5, 0.5) @@ -59,7 +59,7 @@ def test_light_falloff_curve_add_point(self): self.end_test() def test_scene_render_view_add_remove(self): - action = f""" + action = """ import bpy views = bpy.data.scenes[0].render.views bpy.ops.scene.render_view_add() @@ -72,7 +72,7 @@ def test_scene_render_view_add_remove(self): self.end_test() def test_scene_color_management_curve(self): - action = f""" + action = """ import bpy settings = bpy.data.scenes[0].view_settings settings.use_curve_mapping = True diff --git a/tests/process.py b/tests/process.py index 8cf47b6d..ce410a73 100644 --- a/tests/process.py +++ b/tests/process.py @@ -56,7 +56,7 @@ def blender_exe_path() -> str: blender_exe = os.environ.get("MIXER_BLENDER_EXE_PATH") if blender_exe is None: - raise RuntimeError(f"Environment variable MIXER_BLENDER_EXE_PATH is not set") + raise RuntimeError("Environment variable MIXER_BLENDER_EXE_PATH is not set") return blender_exe @@ -70,16 +70,16 @@ def __init__(self): self.command_line: str = None def start(self, args, kwargs): - logger.info(f"Running subprocess.Popen()") + logger.info("Running subprocess.Popen()") logger.info(f"args: {args}") logger.info(f"kwargs: {kwargs}") self.command_line = " ".join(args) logger.info(f"command line: {self.command_line}") try: self._process = subprocess.Popen(args, **kwargs) - logger.info(f"subprocess.popen: success") + logger.info("subprocess.popen: success") except Exception as e: - logger.error(f"Python.start(): Exception raised during subprocess.Popen(): ") + logger.error("Python.start(): Exception raised during subprocess.Popen(): ") logger.error(f"{e}") logger.error(f"args: {args}") logger.error(f"kwargs: {kwargs}")