From c21d4f14b0cfec0de523dc463ee3a61c89ae7cb7 Mon Sep 17 00:00:00 2001 From: swetayadav1 Date: Thu, 2 Nov 2023 14:41:02 +0530 Subject: [PATCH] NXDRIVE-2711: Sourcery refactored --- nxdrive/client/uploader/__init__.py | 11 +++++------ nxdrive/engine/activity.py | 3 +-- tests/unit/test_client_uploader.py | 3 +-- tests/unit/test_engine_dao.py | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/nxdrive/client/uploader/__init__.py b/nxdrive/client/uploader/__init__.py index 50472802e9..601d90db8c 100644 --- a/nxdrive/client/uploader/__init__.py +++ b/nxdrive/client/uploader/__init__.py @@ -451,12 +451,11 @@ def link_blob_to_doc( kwargs["headers"] = headers try: doc_type = kwargs.get("doc_type", "") - if transfer.is_direct_transfer and doc_type and doc_type != "": - res = self._transfer_docType_file(transfer, headers, doc_type) - else: - res = self._transfer_autoType_file(command, blob, kwargs) - - return res + return ( + self._transfer_docType_file(transfer, headers, doc_type) + if transfer.is_direct_transfer and doc_type and doc_type != "" + else self._transfer_autoType_file(command, blob, kwargs) + ) except Exception as exc: err = f"Error while linking blob to doc: {exc!r}" log.warning(err) diff --git a/nxdrive/engine/activity.py b/nxdrive/engine/activity.py index c22a70900a..b8713cefc3 100644 --- a/nxdrive/engine/activity.py +++ b/nxdrive/engine/activity.py @@ -54,8 +54,7 @@ def get_current_action(*, thread_id: int = None) -> Optional["Action"]: @staticmethod def finish_action() -> None: - action = Action.actions.pop(current_thread_id(), None) - if action: + if action := Action.actions.pop(current_thread_id(), None): action.finish() def finish(self) -> None: diff --git a/tests/unit/test_client_uploader.py b/tests/unit/test_client_uploader.py index e8ef8ce23a..f1a2dff404 100644 --- a/tests/unit/test_client_uploader.py +++ b/tests/unit/test_client_uploader.py @@ -13,8 +13,7 @@ def baseuploader(): remote = Remote remote.dao = Mock() - baseuploader = BaseUploader(remote) - return baseuploader + return BaseUploader(remote) def test_link_blob_to_doc(baseuploader, upload, tmp_path, monkeypatch): diff --git a/tests/unit/test_engine_dao.py b/tests/unit/test_engine_dao.py index 1c7f62caa6..1b2a07c2eb 100644 --- a/tests/unit/test_engine_dao.py +++ b/tests/unit/test_engine_dao.py @@ -409,7 +409,7 @@ def test_migration_db_v10(engine_dao): """Verify Downloads after migration from v9 to v10.""" with engine_dao("engine_migration_10.db") as dao: downloads = list(dao.get_downloads()) - assert len(downloads) == 0 + assert not downloads states = list(dao.get_states_from_partial_local(Path())) assert len(states) == 4