From 4d8b7291969b456ad2bc7ea0639c5a12489899b3 Mon Sep 17 00:00:00 2001 From: Thomas Sell Date: Thu, 25 Jan 2024 13:29:35 +0100 Subject: [PATCH] chore: Use Python 3.10+ context manager syntax --- cubi_tk/irods_common.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/cubi_tk/irods_common.py b/cubi_tk/irods_common.py index ee998b8e..cab5f412 100644 --- a/cubi_tk/irods_common.py +++ b/cubi_tk/irods_common.py @@ -173,14 +173,16 @@ def _create_collections(self, job: TransferJob): def put(self, recursive: bool = False, sync: bool = False): # Double tqdm for currently transferred file info - # TODO: add more parenthesis after python 3.10 - with tqdm( - total=self.__total_bytes, - unit="B", - unit_scale=True, - unit_divisor=1024, - position=1, - ) as t, tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log: + with ( + tqdm( + total=self.__total_bytes, + unit="B", + unit_scale=True, + unit_divisor=1024, + position=1, + ) as t, + tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log, + ): for n, job in enumerate(self.__jobs): file_log.set_description_str( f"File [{n + 1}/{len(self.__jobs)}]: {Path(job.path_local).name}" @@ -226,14 +228,16 @@ def get(self): ] self.__total_bytes = sum([job.bytes for job in self.__jobs]) # Double tqdm for currently transferred file info - # TODO: add more parenthesis after python 3.10 - with tqdm( - total=self.__total_bytes, - unit="B", - unit_scale=True, - unit_divisor=1024, - position=1, - ) as t, tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log: + with ( + tqdm( + total=self.__total_bytes, + unit="B", + unit_scale=True, + unit_divisor=1024, + position=1, + ) as t, + tqdm(total=0, position=0, bar_format="{desc}", leave=False) as file_log, + ): for n, job in enumerate(self.__jobs): file_log.set_description_str( f"File [{n + 1}/{len(self.__jobs)}]: {Path(job.path_local).name}"