Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: Apply ruff/pyupgrade rules #3647

Merged
merged 5 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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(

Check warning on line 292 in nipype/pipeline/engine/workflows.py

View check run for this annotation

Codecov / codecov/patch

nipype/pipeline/engine/workflows.py#L292

Added line #L292 was not covered by tests
"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 @@
# 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 @@
time.mktime(time.strptime(job_time_text, "%Y-%m-%dT%H:%M:%S"))
)
except:
job_time = float(0.0)
job_time = 0.0

Check warning on line 228 in nipype/pipeline/plugins/sge.py

View check run for this annotation

Codecov / codecov/patch

nipype/pipeline/plugins/sge.py#L228

Added line #L228 was not covered by tests
# 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 @@
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)}}},"

Check warning on line 133 in nipype/pipeline/plugins/sgegraph.py

View check run for this annotation

Codecov / codecov/patch

nipype/pipeline/plugins/sgegraph.py#L133

Added line #L133 was not covered by tests
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 @@
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)}}}:"

Check warning on line 133 in nipype/pipeline/plugins/slurmgraph.py

View check run for this annotation

Codecov / codecov/patch

nipype/pipeline/plugins/slurmgraph.py#L133

Added line #L133 was not covered by tests
if (
values != ""
): # i.e. if some jobs were added to dependency list
Expand Down