diff --git a/nipype/__init__.py b/nipype/__init__.py index 22e6f97c2d..54872f193e 100644 --- a/nipype/__init__.py +++ b/nipype/__init__.py @@ -25,7 +25,7 @@ import faulthandler faulthandler.enable() -except (ImportError, OSError) as e: +except (ImportError, OSError): pass config = NipypeConfig() diff --git a/nipype/interfaces/cmtk/tests/test_nbs.py b/nipype/interfaces/cmtk/tests/test_nbs.py index 51ea9580cd..efc8aed678 100644 --- a/nipype/interfaces/cmtk/tests/test_nbs.py +++ b/nipype/interfaces/cmtk/tests/test_nbs.py @@ -8,7 +8,7 @@ have_cv = True try: package_check("cviewer") -except Exception as e: +except Exception: have_cv = False @@ -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() diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index eb64dd141d..46cdfb44f2 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -530,7 +530,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) @@ -572,7 +572,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 @@ -2619,7 +2619,6 @@ def _list_outputs(self): ) if len(arg) > maxlen: maxlen = len(arg) - outfiles = [] for i in range(maxlen): argtuple = [] for arg in arglist: diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py index d0af921f09..fc7f03db9f 100644 --- a/nipype/interfaces/tests/test_io.py +++ b/nipype/interfaces/tests/test_io.py @@ -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" diff --git a/nipype/interfaces/utility/tests/test_csv.py b/nipype/interfaces/utility/tests/test_csv.py index 8a8f06e509..2ce78876cc 100644 --- a/nipype/interfaces/utility/tests/test_csv.py +++ b/nipype/interfaces/utility/tests/test_csv.py @@ -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 diff --git a/nipype/pipeline/plugins/base.py b/nipype/pipeline/plugins/base.py index 1ea62c890e..1571ab71a9 100644 --- a/nipype/pipeline/plugins/base.py +++ b/nipype/pipeline/plugins/base.py @@ -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] diff --git a/nipype/pipeline/plugins/tests/test_sgelike.py b/nipype/pipeline/plugins/tests/test_sgelike.py index a150309e1f..26c3d70a06 100644 --- a/nipype/pipeline/plugins/tests/test_sgelike.py +++ b/nipype/pipeline/plugins/tests/test_sgelike.py @@ -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( diff --git a/nipype/sphinxext/plot_workflow.py b/nipype/sphinxext/plot_workflow.py index ca95f56fa3..74745f99cb 100644 --- a/nipype/sphinxext/plot_workflow.py +++ b/nipype/sphinxext/plot_workflow.py @@ -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) diff --git a/nipype/utils/profiler.py b/nipype/utils/profiler.py index 370097e90b..cc2b4f7905 100644 --- a/nipype/utils/profiler.py +++ b/nipype/utils/profiler.py @@ -10,7 +10,7 @@ try: import psutil -except ImportError as exc: +except ImportError: psutil = None