Skip to content

Commit

Permalink
Merge pull request nipy#3647 from DimitriPapadopoulos/UP
Browse files Browse the repository at this point in the history
STY: Apply ruff/pyupgrade rules
  • Loading branch information
effigies committed May 5, 2024
2 parents a17de8e + dea4116 commit d52a62d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 32 deletions.
22 changes: 3 additions & 19 deletions nipype/external/fsl_imglob.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -131,18 +123,10 @@ 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__":
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nipype/pipeline/engine/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions nipype/pipeline/plugins/sge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -227,7 +225,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)
Expand Down
4 changes: 1 addition & 3 deletions nipype/pipeline/plugins/sgegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions nipype/pipeline/plugins/slurmgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d52a62d

Please sign in to comment.