Skip to content

Commit

Permalink
refactor: apply black
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeborn2BeAlive committed Sep 9, 2020
1 parent 42a8fe5 commit 435ae3d
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 36 deletions.
9 changes: 6 additions & 3 deletions extra/inject_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@


def get_version():
cp = subprocess.run(["git", "describe", "--tags", "--dirty", "--match=v*"], stdout=subprocess.PIPE, check=True,)
cp = subprocess.run(
["git", "describe", "--tags", "--dirty", "--match=v*"],
stdout=subprocess.PIPE,
check=True,
)
version = str(cp.stdout, encoding="utf8").strip()
return version


def parse(version) -> Tuple[Tuple[int], str]:
"""Parse version string like "v1.0.4-14-g241472-dirty" into ((0,14,0), "-g241472-dirty")
"""
"""Parse version string like "v1.0.4-14-g241472-dirty" into ((0,14,0), "-g241472-dirty")"""
# similar regexp in gitlab .yml files
# tested with https://regoio.herokuapp.com/

Expand Down
6 changes: 5 additions & 1 deletion mixer/bl_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def collapsable_panel(
):
row = layout.row()
row.prop(
data, property, icon="TRIA_DOWN" if getattr(data, property) else "TRIA_RIGHT", icon_only=True, emboss=False,
data,
property,
icon="TRIA_DOWN" if getattr(data, property) else "TRIA_RIGHT",
icon_only=True,
emboss=False,
)
if alert:
row.alert = True
Expand Down
9 changes: 6 additions & 3 deletions mixer/bl_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,23 @@ def get_snap_view_area(self, context):
return self.snap_view_areas_values

snap_view_user: bpy.props.EnumProperty(
items=get_snap_view_users, name="Snap View User",
items=get_snap_view_users,
name="Snap View User",
)
# todo: this cannot work, it depends on the 3d view panel
# todo: so it should be a property of bpy.types.SpaceView3D probably.
snap_view_area: bpy.props.EnumProperty(items=get_snap_view_area, name="Snap View 3D Area")

snap_time_user_enabled: bpy.props.BoolProperty(default=False)
snap_time_user: bpy.props.EnumProperty(
items=get_snap_view_users, name="Snap Time User",
items=get_snap_view_users,
name="Snap Time User",
)

snap_3d_cursor_user_enabled: bpy.props.BoolProperty(default=False)
snap_3d_cursor_user: bpy.props.EnumProperty(
items=get_snap_view_users, name="Snap 3D Cursor User",
items=get_snap_view_users,
name="Snap 3D Cursor User",
)

display_advanced_room_control: bpy.props.BoolProperty(default=False)
Expand Down
11 changes: 7 additions & 4 deletions mixer/blender_data/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ def load(
is_embedded_data: bool = False,
bpy_data_collection_name: str = None,
):
"""
"""
""""""
if is_embedded_data and bpy_data_collection_name is not None:
logger.error(
f"BpyIDProxy.load() for {bl_instance} : is_embedded_data is True and bpy_prop_collection is {bpy_data_collection_name}. Item ignored"
Expand Down Expand Up @@ -785,7 +784,11 @@ def __init__(self):
self._data: Mapping[str, List] = {}

def load(
self, bl_collection: bpy.types.bpy_prop_collection, item_bl_rna, attr_name: str, visit_state: VisitState,
self,
bl_collection: bpy.types.bpy_prop_collection,
item_bl_rna,
attr_name: str,
visit_state: VisitState,
):
"""
- bl_collection: a collection of structure, e.g. T.Mesh.vertices
Expand Down Expand Up @@ -1376,7 +1379,7 @@ def find(self, collection_name: str, key: str) -> BpyIDProxy:
def update(
self, diff: BpyBlendDiff, context: Context = safe_context, depsgraph_updates: T.bpy_prop_collection = ()
) -> Changeset:
""" Update the proxy using the state of the Blendata collections (ID creation, deletion)
"""Update the proxy using the state of the Blendata collections (ID creation, deletion)
and the depsgraph updates (ID modification)
Sender side
Expand Down
9 changes: 3 additions & 6 deletions mixer/blender_data/specifics.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ def pre_save_id(proxy: Proxy, target: T.ID) -> T.ID:


def pre_save_struct(proxy: Proxy, bpy_struct: T.Struct, attr_name: str):
"""Process attributes that must be saved first
"""
"""Process attributes that must be saved first"""
target = getattr(bpy_struct, attr_name, None)
if target is None:
return None
Expand All @@ -204,8 +203,7 @@ def pre_save_struct(proxy: Proxy, bpy_struct: T.Struct, attr_name: str):


def post_save_id(proxy: Proxy, bpy_id: T.ID):
"""Apply type specific patches after loading bpy_struct into proxy
"""
"""Apply type specific patches after loading bpy_struct into proxy"""
if isinstance(bpy_id, T.Image):
# So far, the receiver has no valid "current file", so he cannot load relative files
for attr_name in ("filepath", "filepath_raw"):
Expand All @@ -226,8 +224,7 @@ def post_save_id(proxy: Proxy, bpy_id: T.ID):


def add_element(proxy: Proxy, collection: T.bpy_prop_collection, key: str):
"""Add an element to a bpy_prop_collection using the collection specific API
"""
"""Add an element to a bpy_prop_collection using the collection specific API"""

bl_rna = getattr(collection, "bl_rna", None)
if bl_rna is not None:
Expand Down
3 changes: 2 additions & 1 deletion mixer/blender_data/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def test_load_as(self):
load_as_what(T.Scene.bl_rna.properties["objects"], bpy.data.scenes[0].objects, root_ids),
)
self.assertEqual(
LoadElementAs.ID_REF, load_as_what(T.Scene.bl_rna.properties["world"], bpy.data.scenes[0].world, root_ids),
LoadElementAs.ID_REF,
load_as_what(T.Scene.bl_rna.properties["world"], bpy.data.scenes[0].world, root_ids),
)
self.assertEqual(
LoadElementAs.ID_DEF,
Expand Down
5 changes: 4 additions & 1 deletion mixer/broadcaster/apps/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ def broadcast_room_update(self, room: Room, attributes: Dict[str, Any]):
return

self.broadcast_to_all_clients(
common.Command(common.MessageType.ROOM_UPDATE, common.encode_json({room.name: attributes}),)
common.Command(
common.MessageType.ROOM_UPDATE,
common.encode_json({room.name: attributes}),
)
)

def set_room_custom_attributes(self, room_name: str, custom_attributes: Mapping[str, Any]):
Expand Down
6 changes: 5 additions & 1 deletion mixer/broadcaster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def connect(self):
self.socket.connect((self.host, self.port))
local_address = self.socket.getsockname()
logger.info(
"Connecting from local %s:%s to %s:%s", local_address[0], local_address[1], self.host, self.port,
"Connecting from local %s:%s to %s:%s",
local_address[0],
local_address[1],
self.host,
self.port,
)
self.send_command(common.Command(common.MessageType.CLIENT_ID))
self.send_command(common.Command(common.MessageType.LIST_CLIENTS))
Expand Down
5 changes: 4 additions & 1 deletion mixer/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def encode(message: Message) -> bytes:
raise NotImplementedError("encode")
buffer = b""
fields = ((f.name, f.type) for f in dataclasses.fields(message))
for name, type_, in fields:
for (
name,
type_,
) in fields:
if type_ not in codec_functions:
raise NotImplementedError(f"No codec_func for {type_}")
encode = codec_functions[type_][0]
Expand Down
9 changes: 3 additions & 6 deletions tests/blender/blender_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def sort(d):


class TestGeneric(BlenderTestCase):
"""Unittest that joins a room before message creation
"""
"""Unittest that joins a room before message creation"""

def setUp(self, join: bool = True):
sender_blendfile = files_folder() / "empty.blend"
Expand All @@ -76,16 +75,14 @@ def setUp(self, join: bool = True):


class TestGenericJoinBefore(TestGeneric):
"""Unittest that joins a room before message creation
"""
"""Unittest that joins a room before message creation"""

def setUp(self):
super().setUp(join=True)


class TestGenericJoinAfter(TestGeneric):
"""Unittest that does not join a room before message creation
"""
"""Unittest that does not join a room before message creation"""

def setUp(self):
super().setUp(join=False)
4 changes: 3 additions & 1 deletion tests/blender_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def setup(self, blender_args: List = None, env: Optional[Mapping[str, str]] = No
self._blender.start(blender_args, env)
self._blender.connect()

def connect_mixer(self,):
def connect_mixer(
self,
):
if self._log_level is not None:
self._blender.send_function(mixer_lib.set_log_level, self._log_level)
self._blender.send_function(mixer_lib.connect)
Expand Down
6 changes: 4 additions & 2 deletions tests/blender_manual/test_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def test_update_object(self):


@parameterized_class(
[{"experimental_sync": True}, {"experimental_sync": False}], class_name_func=ThrottledTestCase.get_class_name,
[{"experimental_sync": True}, {"experimental_sync": False}],
class_name_func=ThrottledTestCase.get_class_name,
)
class TestSceneRename(ThrottledTestCase):
def setUp(self):
Expand All @@ -143,7 +144,8 @@ def test_add_object(self):

def test_collection_new_and_link(self):
self.send_strings(
[bl.data_collections_new("new_collection"), bl.scene_collection_children_link("new_collection")], to=0,
[bl.data_collections_new("new_collection"), bl.scene_collection_children_link("new_collection")],
to=0,
)
delay = 0.0
time.sleep(delay)
Expand Down
3 changes: 2 additions & 1 deletion tests/vrtist/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


@parameterized_class(
[{"experimental_sync": True}, {"experimental_sync": False}], class_name_func=VRtistTestCase.get_class_name,
[{"experimental_sync": True}, {"experimental_sync": False}],
class_name_func=VRtistTestCase.get_class_name,
)
class TestCollection(VRtistTestCase):
def setUp(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/vrtist/test_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def assert_matches(self):


@parameterized_class(
[{"experimental_sync": True}, {"experimental_sync": False}], class_name_func=ThrottledTestCase.get_class_name,
[{"experimental_sync": True}, {"experimental_sync": False}],
class_name_func=ThrottledTestCase.get_class_name,
)
class TestSimultaneousCreate(ThrottledTestCase):
def setUp(self):
Expand Down
9 changes: 6 additions & 3 deletions tests/vrtist/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


@parameterized_class(
[{"experimental_sync": True}, {"experimental_sync": False}], class_name_func=VRtistTestCase.get_class_name,
[{"experimental_sync": True}, {"experimental_sync": False}],
class_name_func=VRtistTestCase.get_class_name,
)
class TestSpontaneousRename(VRtistTestCase):
def setUp(self):
Expand Down Expand Up @@ -49,7 +50,8 @@ def test_light(self):


@parameterized_class(
[{"experimental_sync": True}, {"experimental_sync": False}], class_name_func=VRtistTestCase.get_class_name,
[{"experimental_sync": True}, {"experimental_sync": False}],
class_name_func=VRtistTestCase.get_class_name,
)
class TestReferencedDatablock(VRtistTestCase):
"""
Expand Down Expand Up @@ -99,7 +101,8 @@ def test_material(self):


@parameterized_class(
[{"experimental_sync": True}], class_name_func=VRtistTestCase.get_class_name,
[{"experimental_sync": True}],
class_name_func=VRtistTestCase.get_class_name,
)
class TestRenameDatablock(VRtistTestCase):
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/vrtist/test_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


@parameterized_class(
[{"experimental_sync": True}, {"experimental_sync": False}], class_name_func=VRtistTestCase.get_class_name,
[{"experimental_sync": True}, {"experimental_sync": False}],
class_name_func=VRtistTestCase.get_class_name,
)
class TestSceneEmptyDoc(VRtistTestCase):
def setUp(self):
Expand Down

0 comments on commit 435ae3d

Please sign in to comment.