Skip to content

Commit

Permalink
STY: Apply ruff/Pyflakes rule F841
Browse files Browse the repository at this point in the history
F841 Local variable is assigned to but never used

I have left a few occurrences, to be examined later.
  • Loading branch information
DimitriPapadopoulos committed Sep 22, 2024
1 parent 37c8f3b commit e7fffd7
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion nipype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import faulthandler

faulthandler.enable()
except (ImportError, OSError) as e:
except (ImportError, OSError):
pass

config = NipypeConfig()
Expand Down
4 changes: 2 additions & 2 deletions nipype/interfaces/cmtk/tests/test_nbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
have_cv = True
try:
package_check("cviewer")
except Exception as e:
except Exception:
have_cv = False


Expand Down Expand Up @@ -39,7 +39,7 @@ def test_importerror(creating_graphs, tmpdir):
nbs.inputs.in_group2 = group2
nbs.inputs.edge_key = "weight"

with pytest.raises(ImportError) as e:
with pytest.raises(ImportError):
nbs.run()


Expand Down
5 changes: 2 additions & 3 deletions nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def _fetch_bucket(self, bucket_name):
try:
import boto3
import botocore
except ImportError as exc:
except ImportError:
err_msg = "Boto3 package is not installed - install boto3 and try again."
raise Exception(err_msg)

Expand Down Expand Up @@ -571,7 +571,7 @@ def _fetch_bucket(self, bucket_name):
# And try fetch the bucket with the name argument
try:
_get_head_bucket(s3_resource, bucket_name)
except Exception as exc:
except Exception:
# Try to connect anonymously
s3_resource.meta.client.meta.events.register(
"choose-signer.s3.*", botocore.handlers.disable_signing
Expand Down Expand Up @@ -2621,7 +2621,6 @@ def _list_outputs(self):
)
if len(arg) > maxlen:
maxlen = len(arg)
outfiles = []
for i in range(maxlen):
argtuple = []
for arg in arglist:
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def test_freesurfersource():

def test_freesurfersource_incorrectdir():
fss = nio.FreeSurferSource()
with pytest.raises(TraitError) as err:
with pytest.raises(TraitError):
fss.inputs.subjects_dir = "path/to/no/existing/directory"


Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/utility/tests/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def test_csvReader(tmpdir):


def test_csvReader_quoted(tmpdir):
header = "files,labels,erosion\n"
lines = ['foo,"hello, world",300.1\n']

name = tmpdir.join("testfile.csv").strpath
Expand Down
2 changes: 1 addition & 1 deletion nipype/pipeline/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def _get_result(self, taskid):
"Node working directory: ({}) ".format(taskid, timeout, node_dir)
)
raise OSError(error_message)
except OSError as e:
except OSError:
result_data["traceback"] = "\n".join(format_exception(*sys.exc_info()))
else:
results_file = glob(os.path.join(node_dir, "result_*.pklz"))[0]
Expand Down
2 changes: 1 addition & 1 deletion nipype/pipeline/plugins/tests/test_sgelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_crashfile_creation(tmp_path):
pipe.config["execution"]["crashdump_dir"] = str(tmp_path)
pipe.add_nodes([pe.Node(interface=Function(function=crasher), name="crasher")])
sgelike_plugin = SGELikeBatchManagerBase("")
with pytest.raises(RuntimeError) as e:
with pytest.raises(RuntimeError):
assert pipe.run(plugin=sgelike_plugin)

crashfiles = list(tmp_path.glob("crash*crasher*.pklz")) + list(
Expand Down
2 changes: 1 addition & 1 deletion nipype/sphinxext/plot_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def _dummy_print(*arg, **kwarg):
exec(code, ns)
if function_name is not None:
exec(function_name + "()", ns)
except (Exception, SystemExit) as err:
except (Exception, SystemExit):
raise GraphError(traceback.format_exc())
finally:
os.chdir(pwd)
Expand Down
2 changes: 1 addition & 1 deletion nipype/utils/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

try:
import psutil
except ImportError as exc:
except ImportError:
psutil = None


Expand Down

0 comments on commit e7fffd7

Please sign in to comment.