From fc63aaaffe63f515c7794dd144f398a61d71599b Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 5 May 2024 16:10:21 +0200 Subject: [PATCH 1/5] STY: Apply ruff/pyupgrade rule UP018 UP018 Unnecessary `float` call (rewrite as a literal) --- nipype/pipeline/plugins/sge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/pipeline/plugins/sge.py b/nipype/pipeline/plugins/sge.py index 8ddbb31791..9617c18945 100644 --- a/nipype/pipeline/plugins/sge.py +++ b/nipype/pipeline/plugins/sge.py @@ -227,7 +227,7 @@ def _parse_qstat_job_list(self, xml_job_list): time.mktime(time.strptime(job_time_text, "%Y-%m-%dT%H:%M:%S")) ) except: - job_time = float(0.0) + job_time = 0.0 # Make job entry task_id = int(job_num) From c7d24212a4ae8a8330abbf378bba178601217d6e Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 5 May 2024 16:11:19 +0200 Subject: [PATCH 2/5] STY: Apply ruff/pyupgrade rule UP024 UP024 Replace aliased errors with `OSError` --- nipype/interfaces/io.py | 2 +- nipype/pipeline/engine/workflows.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index 975fe4537f..1ed82022e5 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -84,7 +84,7 @@ def copytree(src, dst, use_hardlink=False): hashmethod="content", use_hardlink=use_hardlink, ) - except (OSError, os.error) as why: + except OSError as why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files diff --git a/nipype/pipeline/engine/workflows.py b/nipype/pipeline/engine/workflows.py index 6983c49cc3..dfbc7fad1c 100644 --- a/nipype/pipeline/engine/workflows.py +++ b/nipype/pipeline/engine/workflows.py @@ -289,7 +289,7 @@ def disconnect(self, *args): for srcnode, dstnode, conn in connection_list: logger.debug("disconnect(): %s->%s %s", srcnode, dstnode, str(conn)) if self in [srcnode, dstnode]: - raise IOError( + raise OSError( "Workflow connect cannot contain itself as node: src[%s] " "dest[%s] workflow[%s]" ) % (srcnode, dstnode, self.name) From 2f161d5d50837db38dd03ffa0b1fc47ae2f11464 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 5 May 2024 16:15:00 +0200 Subject: [PATCH 3/5] STY: Apply ruff/pyupgrade rule UP030 UP030 Use implicit references for positional format fields --- nipype/pipeline/plugins/sge.py | 6 ++---- nipype/pipeline/plugins/sgegraph.py | 4 +--- nipype/pipeline/plugins/slurmgraph.py | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/nipype/pipeline/plugins/sge.py b/nipype/pipeline/plugins/sge.py index 9617c18945..c588c0478a 100644 --- a/nipype/pipeline/plugins/sge.py +++ b/nipype/pipeline/plugins/sge.py @@ -91,10 +91,8 @@ def is_job_state_pending(self): # if initializing for more than 5 minute, failure due to # initialization and completion before registration sge_debug_print( - "FAILURE! QJobInfo.IsPending found long running at {1} seconds" - "'initializing' returning False for to break loop!\n{0}".format( - self, time_diff - ) + f"FAILURE! QJobInfo.IsPending found long running at {time_diff} seconds " + f"'initializing' returning False for to break loop!\n{self}" ) is_pending_status = True # Job initialization took too long, so report! else: # self.is_running() || self.is_pending(): diff --git a/nipype/pipeline/plugins/sgegraph.py b/nipype/pipeline/plugins/sgegraph.py index ad5fb78c44..c116a1848c 100644 --- a/nipype/pipeline/plugins/sgegraph.py +++ b/nipype/pipeline/plugins/sgegraph.py @@ -130,9 +130,7 @@ def make_job_name(jobnumber, nodeslist): not self._dont_resubmit_completed_jobs or not cache_doneness_per_node[jobid] ): - values += "${{{0}}},".format( - make_job_name(jobid, nodes) - ) + values += f"${{{make_job_name(jobid, nodes)}}}," if ( values != " " ): # i.e. if some jobs were added to dependency list diff --git a/nipype/pipeline/plugins/slurmgraph.py b/nipype/pipeline/plugins/slurmgraph.py index 7d9ff0cc41..6033e5316a 100644 --- a/nipype/pipeline/plugins/slurmgraph.py +++ b/nipype/pipeline/plugins/slurmgraph.py @@ -130,9 +130,7 @@ def make_job_name(jobnumber, nodeslist): not self._dont_resubmit_completed_jobs or not cache_doneness_per_node[jobid] ): - values += "${{{0}}}:".format( - make_job_name(jobid, nodes) - ) + values += f"${{{make_job_name(jobid, nodes)}}}:" if ( values != "" ): # i.e. if some jobs were added to dependency list From 65ea93fe0e81a68a1192fa3fca9da55c40323d4d Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 5 May 2024 16:16:48 +0200 Subject: [PATCH 4/5] STY: Apply ruff/pyupgrade rule UP036 UP036 Version block is outdated for minimum Python version --- nipype/external/fsl_imglob.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/nipype/external/fsl_imglob.py b/nipype/external/fsl_imglob.py index 3f131c33b3..93dfa80626 100755 --- a/nipype/external/fsl_imglob.py +++ b/nipype/external/fsl_imglob.py @@ -91,14 +91,6 @@ def main(): if len(sys.argv) <= 1: usage() - if sys.version_info < (2, 4): - import sets - from sets import Set - - setAvailable = False - else: - setAvailable = True - deleteExtensions = True primaryExtensions = [".nii.gz", ".nii", ".hdr.gz", ".hdr"] secondaryExtensions = [".img.gz", ".img"] @@ -131,18 +123,13 @@ def main(): ) if deleteExtensions: - for file in range(0, len(filelist)): - filelist[file] = removeImageExtension(filelist[file], allExtensions) - if setAvailable: - filelist = list(set(filelist)) - else: - filelist = list(Set(filelist)) - filelist.sort() + filelist = [ + removeImageExtension(f, allExtensions) + for f in filelist + ] + filelist = sorted(set(filelist)) - for file in range(0, len(filelist)): - print(filelist[file], end=" ") - if file < len(filelist) - 1: - print(" ", end=" ") + print(*filelist, sep= " ", end=" ") if __name__ == "__main__": From dea411604d114b6dc5a5414c227e11318e1fa987 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 5 May 2024 17:38:29 +0200 Subject: [PATCH 5/5] STY: another round of black --- nipype/external/fsl_imglob.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nipype/external/fsl_imglob.py b/nipype/external/fsl_imglob.py index 93dfa80626..46ae5f2549 100755 --- a/nipype/external/fsl_imglob.py +++ b/nipype/external/fsl_imglob.py @@ -123,13 +123,10 @@ def main(): ) if deleteExtensions: - filelist = [ - removeImageExtension(f, allExtensions) - for f in filelist - ] + filelist = [removeImageExtension(f, allExtensions) for f in filelist] filelist = sorted(set(filelist)) - print(*filelist, sep= " ", end=" ") + print(*filelist, sep=" ", end=" ") if __name__ == "__main__":