From 435ae3daedb28e9a93d32d68e34d0a19f8010d21 Mon Sep 17 00:00:00 2001 From: Celeborn2BeAlive Date: Wed, 9 Sep 2020 19:08:53 +0200 Subject: [PATCH] refactor: apply black --- extra/inject_version.py | 9 ++++++--- mixer/bl_panels.py | 6 +++++- mixer/bl_properties.py | 9 ++++++--- mixer/blender_data/proxy.py | 11 +++++++---- mixer/blender_data/specifics.py | 9 +++------ mixer/blender_data/tests/test_core.py | 3 ++- mixer/broadcaster/apps/server.py | 5 ++++- mixer/broadcaster/client.py | 6 +++++- mixer/codec.py | 5 ++++- tests/blender/blender_testcase.py | 9 +++------ tests/blender_app.py | 4 +++- tests/blender_manual/test_conflicts.py | 6 ++++-- tests/vrtist/test_collection.py | 3 ++- tests/vrtist/test_conflicts.py | 3 ++- tests/vrtist/test_misc.py | 9 ++++++--- tests/vrtist/test_scene.py | 3 ++- 16 files changed, 64 insertions(+), 36 deletions(-) diff --git a/extra/inject_version.py b/extra/inject_version.py index a265ac61..3a94e2ea 100644 --- a/extra/inject_version.py +++ b/extra/inject_version.py @@ -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/ diff --git a/mixer/bl_panels.py b/mixer/bl_panels.py index 98f6d6f4..81c692ef 100644 --- a/mixer/bl_panels.py +++ b/mixer/bl_panels.py @@ -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 diff --git a/mixer/bl_properties.py b/mixer/bl_properties.py index 694fafae..e7b2dca8 100644 --- a/mixer/bl_properties.py +++ b/mixer/bl_properties.py @@ -191,7 +191,8 @@ 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. @@ -199,12 +200,14 @@ def get_snap_view_area(self, context): 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) diff --git a/mixer/blender_data/proxy.py b/mixer/blender_data/proxy.py index c268fdfd..2fa4a7ee 100644 --- a/mixer/blender_data/proxy.py +++ b/mixer/blender_data/proxy.py @@ -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" @@ -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 @@ -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 diff --git a/mixer/blender_data/specifics.py b/mixer/blender_data/specifics.py index 5c4742ab..30324a6b 100644 --- a/mixer/blender_data/specifics.py +++ b/mixer/blender_data/specifics.py @@ -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 @@ -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"): @@ -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: diff --git a/mixer/blender_data/tests/test_core.py b/mixer/blender_data/tests/test_core.py index 7c6d34db..1b7910e2 100644 --- a/mixer/blender_data/tests/test_core.py +++ b/mixer/blender_data/tests/test_core.py @@ -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, diff --git a/mixer/broadcaster/apps/server.py b/mixer/broadcaster/apps/server.py index 6a46dfe9..1b0f23a7 100644 --- a/mixer/broadcaster/apps/server.py +++ b/mixer/broadcaster/apps/server.py @@ -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]): diff --git a/mixer/broadcaster/client.py b/mixer/broadcaster/client.py index 788c5094..2606621a 100644 --- a/mixer/broadcaster/client.py +++ b/mixer/broadcaster/client.py @@ -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)) diff --git a/mixer/codec.py b/mixer/codec.py index d4ce937a..77199b13 100644 --- a/mixer/codec.py +++ b/mixer/codec.py @@ -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] diff --git a/tests/blender/blender_testcase.py b/tests/blender/blender_testcase.py index 20a69e6d..a85b9144 100644 --- a/tests/blender/blender_testcase.py +++ b/tests/blender/blender_testcase.py @@ -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" @@ -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) diff --git a/tests/blender_app.py b/tests/blender_app.py index 66ae7d4b..a3fd5e3b 100644 --- a/tests/blender_app.py +++ b/tests/blender_app.py @@ -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) diff --git a/tests/blender_manual/test_conflicts.py b/tests/blender_manual/test_conflicts.py index c015181b..0da5e918 100644 --- a/tests/blender_manual/test_conflicts.py +++ b/tests/blender_manual/test_conflicts.py @@ -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): @@ -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) diff --git a/tests/vrtist/test_collection.py b/tests/vrtist/test_collection.py index 92023d89..d1b32d9e 100644 --- a/tests/vrtist/test_collection.py +++ b/tests/vrtist/test_collection.py @@ -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): diff --git a/tests/vrtist/test_conflicts.py b/tests/vrtist/test_conflicts.py index edeb614f..82d0bd7d 100644 --- a/tests/vrtist/test_conflicts.py +++ b/tests/vrtist/test_conflicts.py @@ -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): diff --git a/tests/vrtist/test_misc.py b/tests/vrtist/test_misc.py index 3501065d..c13fd5eb 100644 --- a/tests/vrtist/test_misc.py +++ b/tests/vrtist/test_misc.py @@ -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): @@ -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): """ @@ -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): """ diff --git a/tests/vrtist/test_scene.py b/tests/vrtist/test_scene.py index f3c0754d..41edda8a 100644 --- a/tests/vrtist/test_scene.py +++ b/tests/vrtist/test_scene.py @@ -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):