From 3efe0ac54499bd9e9d2057a75bf59fdc10f95a1c Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 9 Aug 2021 20:20:19 +0200 Subject: [PATCH 1/4] FIX: LGTM error: Special method has incorrect signature Too few parameters for special method __getitem__, which has 1 parameter, but should have 2, in class FileBasedImage. https://lgtm.com/rules/7850093/ --- nibabel/filebasedimages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nibabel/filebasedimages.py b/nibabel/filebasedimages.py index 4fab9451c3..3fd5b5fc8f 100644 --- a/nibabel/filebasedimages.py +++ b/nibabel/filebasedimages.py @@ -202,7 +202,7 @@ def __init__(self, header=None, extra=None, file_map=None): def header(self): return self._header - def __getitem__(self): + def __getitem__(self, key): """ No slicing or dictionary interface for images """ raise TypeError("Cannot slice image objects.") From c3a0e98286ccc51645127a9624e0799d8502e2b7 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 9 Aug 2021 20:23:50 +0200 Subject: [PATCH 2/4] FIX: LGTM warning: Unnecessary 'else' clause in loop This 'for' statement has a redundant 'else' as no 'break' is present in the body. https://lgtm.com/rules/5980098/ --- nibabel/cifti2/cifti2.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nibabel/cifti2/cifti2.py b/nibabel/cifti2/cifti2.py index 0b2b7f2a9a..948fe0d0d0 100644 --- a/nibabel/cifti2/cifti2.py +++ b/nibabel/cifti2/cifti2.py @@ -1156,8 +1156,7 @@ def get_index_map(self, index): a2md = self._get_indices_from_mim(v) if index in a2md: return v - else: - raise Cifti2HeaderError("Index not mapped") + raise Cifti2HeaderError("Index not mapped") def _validate_new_mim(self, value): if value.applies_to_matrix_dimension is None: From bcb41dd967ca89cde40360ba17aa729128901ec7 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 9 Aug 2021 20:25:32 +0200 Subject: [PATCH 3/4] FIX: LGTM warning: Variable defined multiple times This assignment to 'patient_info' is unnecessary as it is redefined here before this value is used. https://lgtm.com/rules/1800095/ --- nibabel/cmdline/dicomfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nibabel/cmdline/dicomfs.py b/nibabel/cmdline/dicomfs.py index 6e53be103b..be3acad269 100644 --- a/nibabel/cmdline/dicomfs.py +++ b/nibabel/cmdline/dicomfs.py @@ -71,7 +71,7 @@ def get_paths(self): for study in dft.get_studies(self.dicom_path, self.followlinks): pd = paths.setdefault(study.patient_name_or_uid(), {}) patient_info = 'patient information\n' - patient_info = f'name: {study.patient_name}\n' + patient_info += f'name: {study.patient_name}\n' patient_info += f'ID: {study.patient_id}\n' patient_info += f'birth date: {study.patient_birth_date}\n' patient_info += f'sex: {study.patient_sex}\n' From cb7243835d01d472e46d4e215150f3293008235d Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 9 Aug 2021 20:35:52 +0200 Subject: [PATCH 4/4] FIX: LGTM recommendations: Unused import Import of '...' is not used. https://lgtm.com/rules/6770079/ --- nibabel/pydicom_compat.py | 1 - nisext/py3builder.py | 3 --- setup.py | 1 - tools/make_tarball.py | 2 -- tools/mpkg_wrapper.py | 2 -- 5 files changed, 9 deletions(-) diff --git a/nibabel/pydicom_compat.py b/nibabel/pydicom_compat.py index 9cca2a293d..b1ee685328 100644 --- a/nibabel/pydicom_compat.py +++ b/nibabel/pydicom_compat.py @@ -23,7 +23,6 @@ # Module has (apparently) unused imports; stop flake8 complaining # flake8: noqa -import numpy as np from .deprecated import deprecate_with_version have_dicom = True diff --git a/nisext/py3builder.py b/nisext/py3builder.py index 4f82a8cfb2..7bcaf2348c 100644 --- a/nisext/py3builder.py +++ b/nisext/py3builder.py @@ -1,9 +1,6 @@ """ distutils utilities for porting to python 3 within 2-compatible tree """ -import sys -import re - try: from distutils.command.build_py import build_py_2to3 except ImportError: diff --git a/setup.py b/setup.py index 9c281a032c..29fb3642da 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ """Build helper.""" import sys -import os from setuptools import setup import versioneer diff --git a/tools/make_tarball.py b/tools/make_tarball.py index 149837aaf5..afbde3d48d 100755 --- a/tools/make_tarball.py +++ b/tools/make_tarball.py @@ -4,8 +4,6 @@ import commands import os -import sys -import shutil from toollib import * diff --git a/tools/mpkg_wrapper.py b/tools/mpkg_wrapper.py index c050bd0f8c..d79f84caad 100644 --- a/tools/mpkg_wrapper.py +++ b/tools/mpkg_wrapper.py @@ -16,8 +16,6 @@ __docformat__ = 'restructuredtext' import sys -import setuptools -import bdist_mpkg def main(): del sys.argv[0]