Skip to content

Commit

Permalink
refactor: fix or ignore flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeborn2BeAlive committed Sep 9, 2020
1 parent 435ae3d commit 38275c0
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 48 deletions.
15 changes: 8 additions & 7 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
max-line-length = 120
ignore = E203, E501, W503 # Incompatible with black

exclude =
.git
.history
.venv
.vscode
__pycache__
gitlab/blender
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")'
4 changes: 2 additions & 2 deletions mixer/bl_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mixer/bl_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
10 changes: 5 additions & 5 deletions mixer/blender_client/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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} ")


Expand All @@ -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}")


Expand Down Expand Up @@ -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} ")


Expand Down
2 changes: 1 addition & 1 deletion mixer/blender_client/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mixer/blender_client/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions mixer/blender_client/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} ")


Expand Down Expand Up @@ -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} ")
2 changes: 1 addition & 1 deletion mixer/blender_data/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""

Expand Down
6 changes: 3 additions & 3 deletions mixer/blender_data/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mixer/broadcaster/apps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion mixer/broadcaster/apps/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions tests/blender/test_blenddata_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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))
Expand All @@ -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"]
Expand All @@ -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"]
Expand Down
14 changes: 7 additions & 7 deletions tests/blender/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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()
Expand All @@ -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')
"""
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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}")
Expand Down

0 comments on commit 38275c0

Please sign in to comment.