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

Enable Pylint warning unused-import #4518

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
4 changes: 2 additions & 2 deletions package/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ enable=abstract-class-instantiated,
unsubscriptable-object,
unsupported-binary-operation,
unsupported-membership-test,
unused-import,
unused-format-string-argument,
unused-format-string-key,
useless-else-on-loop,
Expand Down Expand Up @@ -260,7 +261,6 @@ enable=abstract-class-instantiated,
# unnecessary-semicolon,
# unpacking-non-sequence,
# unused-argument,
# unused-import,
# unused-variable,
# unused-wildcard-import,
# used-before-assignment,
Expand Down Expand Up @@ -609,4 +609,4 @@ analyse-fallback-blocks=no

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Chronological list of authors
- Sampurna Mukherjee
- Leon Wehrhan
- Valerij Talagayev
- Daniil Vakhrameev



Expand Down
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Enhancements
DOI 10.1021/acs.jpcb.7b11988. (Issue #2039, PR #4524)

Changes
* Enabled pylint warning 'unused-imports' (issue #1295, PR #4518)
* As per SPEC0 the minimum supported Python version has been raised
to 3.10 (PR #4502)
* MDAnalysis.analysis.hole2 is now directly imported from the mdakit
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/analysis/bat.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class to calculate dihedral angles for a given set of atoms or residues

"""
import logging
import warnings

import numpy as np
import copy
Expand Down
4 changes: 0 additions & 4 deletions package/MDAnalysis/analysis/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,7 @@ def is_any_closer(r, r0, dist=2.5):
.. footbibliography::

"""
import os
import errno
import warnings
import bz2
import functools

import numpy as np
Expand All @@ -220,7 +217,6 @@ def is_any_closer(r, r0, dist=2.5):

import MDAnalysis
import MDAnalysis.lib.distances
from MDAnalysis.lib.util import openany
from MDAnalysis.analysis.distances import distance_array
from MDAnalysis.core.groups import AtomGroup, UpdatingAtomGroup
from .base import AnalysisBase
Expand Down
13 changes: 1 addition & 12 deletions package/MDAnalysis/analysis/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,12 @@

"""
import numpy as np
import sys
import os
import os.path
import errno
import warnings

from gridData import Grid

import MDAnalysis
from MDAnalysis.core import groups
from MDAnalysis.lib.util import (fixedwidth_bins, iterable, asiterable,
deprecate,)
from MDAnalysis.lib import NeighborSearch as NS
from MDAnalysis import NoDataError, MissingDataWarning
from MDAnalysis.lib.util import fixedwidth_bins
from .. import units
from ..lib import distances
from MDAnalysis.lib.log import ProgressBar

from .base import AnalysisBase

Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/analysis/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
from MDAnalysis.lib.distances import calc_bonds


import warnings
import logging
logger = logging.getLogger("MDAnalysis.analysis.distances")

Expand Down
3 changes: 0 additions & 3 deletions package/MDAnalysis/analysis/encore/confdistmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ class to compute an RMSD matrix in such a way is also available.
from getpass import getuser
from socket import gethostname
from datetime import datetime
from time import sleep
import logging
import warnings

from ...core.universe import Universe

from ..align import rotation_matrix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
.. versionadded:: 0.16.0

"""
import logging
import warnings

# Import native affinity propagation implementation
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/analysis/encore/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@
.. All functions are included via automodule :members:.

"""
import warnings
import logging

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/analysis/encore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from multiprocessing import Process, Manager
from joblib import cpu_count
import numpy as np
import sys

import MDAnalysis as mda
from ...coordinates.memory import MemoryReader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def analysis(current, output, u, **kwargs):
from ..base import AnalysisBase
from MDAnalysis.lib.NeighborSearch import AtomNeighborSearch
from MDAnalysis.lib.distances import capped_distance, calc_angles
from MDAnalysis import NoDataError, MissingDataWarning, SelectionError
from MDAnalysis import NoDataError, MissingDataWarning

logger = logging.getLogger('MDAnalysis.analysis.WaterBridgeAnalysis')

Expand Down
5 changes: 2 additions & 3 deletions package/MDAnalysis/analysis/legacy/x3dna.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
.. autoexception:: ApplicationError

"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have no tests for this module - I would suggest not touching imports here

import glob
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing glob here is ok because it's imported when needed in the code.

import os
import errno
import shutil
Expand All @@ -131,8 +130,8 @@
import numpy as np
import matplotlib.pyplot as plt

from MDAnalysis import ApplicationError
from MDAnalysis.lib.util import which, realpath, asiterable, deprecate
from MDAnalysis import ApplicationError # pylint: disable=unused-import # module will be removed in 3.0.0
from MDAnalysis.lib.util import which, realpath, asiterable, deprecate # pylint: disable=unused-import

import logging

Expand Down
2 changes: 0 additions & 2 deletions package/MDAnalysis/analysis/lineardensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
cartesian axes [xyz] of the simulation cell. Works only for orthorombic,
fixed volume cells (thus for simulations in canonical NVT ensemble).
"""
import os.path as path

import numpy as np
import warnings

Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/nucleicacids.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

import MDAnalysis as mda
from .distances import calc_bonds
from .base import AnalysisBase, Results
from .base import AnalysisBase
from MDAnalysis.core.groups import Residue, ResidueGroup


Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/psa.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

import warnings

from pathsimanalysis import (
from pathsimanalysis import ( # pylint: disable=unused-import # will be removed completely in version 3.0.0
get_path_metric_func,
sqnorm,
get_msd_matrix,
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

import MDAnalysis.lib.qcprot as qcp
from MDAnalysis.analysis.base import AnalysisBase
from MDAnalysis.exceptions import SelectionError, NoDataError
from MDAnalysis.exceptions import SelectionError
from MDAnalysis.lib.util import asiterable, iterable, get_weights


Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/waterdynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"""
import warnings

from waterdynamics.waterdynamics import (
from waterdynamics.waterdynamics import ( # pylint: disable=unused-import #will be removed in version 3.0.0
WaterOrientationalRelaxation,
AngularDistribution,
MeanSquareDisplacement,
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/auxiliary/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import numpy as np

from ..lib.util import asiterable, anyopen
from .. import units

from . import _AUXREADERS
from .core import auxreader
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/converters/ParmEd.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
from . import base
from ..coordinates.base import SingleFrameReaderBase
from ..topology.tables import SYMB2Z
from ..core.universe import Universe
from ..exceptions import NoDataError


Expand Down
6 changes: 1 addition & 5 deletions package/MDAnalysis/coordinates/DCD.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,11 @@
:inherited-members:

"""
import os
import errno
import numpy as np
import struct
import types
import warnings

from .. import units as mdaunits # use mdaunits instead of units to avoid a clash
from . import base, core
from . import base
from ..lib.formats.libdcd import DCDFile
from ..lib.mdamath import triclinic_box
from ..lib.util import store_init_arguments
Expand Down
6 changes: 3 additions & 3 deletions package/MDAnalysis/coordinates/DLPoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import numpy as np

from . import base
from . import core
from ..lib.mdamath import triclinic_box
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we like using triclinic_box() better than mdamath.triclinic_box()?

Personally, I generally prefer non-local objects to have at least one level of provenance attached to their name but I won't block over choosing the bare import.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there are other reviewers that want to change to

from ..lib import mdamath

...
mdamath.triclinic_box(...)

leave it as is, at least it's consistently used throughout.

from ..lib import util
from ..lib.util import cached, store_init_arguments

Expand Down Expand Up @@ -123,7 +123,7 @@ def _read_first_frame(self):
if has_forces:
ts._forces = forces
if not imcon == 0:
ts.dimensions = core.triclinic_box(*unitcell)
ts.dimensions = triclinic_box(*unitcell)

ts.frame = 0

Expand Down Expand Up @@ -176,7 +176,7 @@ def _read_next_timestep(self, ts=None):
unitcell[0] = self._file.readline().split()
unitcell[1] = self._file.readline().split()
unitcell[2] = self._file.readline().split()
ts.dimensions = core.triclinic_box(*unitcell)
ts.dimensions = triclinic_box(*unitcell)

# If ids are given, put them in here
# and later sort by them
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/DMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import sqlite3

from . import base
from .core import triclinic_box
from ..lib.mdamath import triclinic_box


class DMSReader(base.SingleFrameReaderBase):
Expand Down
5 changes: 1 addition & 4 deletions package/MDAnalysis/coordinates/FHIAIMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,15 @@
.. _FHI-AIMS format: https://doi.org/10.6084/m9.figshare.12413477.v1

"""
import re

import itertools
import warnings

import numpy as np

from . import base
from .core import triclinic_box, triclinic_vectors
from ..lib.mdamath import triclinic_box
from ..exceptions import NoDataError
from ..lib import util
from ..lib import mdamath


class FHIAIMSReader(base.SingleFrameReaderBase):
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/GRO.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
import numpy as np

from . import base
from .core import triclinic_box, triclinic_vectors
from ..lib.mdamath import triclinic_box
from ..exceptions import NoDataError
from ..lib import util
from .timestep import Timestep
Expand Down
5 changes: 3 additions & 2 deletions package/MDAnalysis/coordinates/H5MD.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@

import numpy as np
import MDAnalysis as mda
from . import base, core
from . import base
from ..exceptions import NoDataError
from ..due import due, Doi
from MDAnalysis.lib.util import store_init_arguments
from MDAnalysis.lib.mdamath import triclinic_box
Comment on lines 216 to +217
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change these to relative imports like everything else?

Suggested change
from MDAnalysis.lib.util import store_init_arguments
from MDAnalysis.lib.mdamath import triclinic_box
from ..lib.util import store_init_arguments
from ..lib.mdamath import triclinic_box

try:
import h5py
except ImportError:
Expand Down Expand Up @@ -652,7 +653,7 @@ def _read_frame(self, frame):
if edges.shape == (3,):
ts.dimensions = [*edges, 90, 90, 90]
else:
ts.dimensions = core.triclinic_box(*edges)
ts.dimensions = triclinic_box(*edges)
else:
ts.dimensions = None

Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/coordinates/PDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@
from ..lib.util import store_init_arguments
from . import base
from .timestep import Timestep
from ..topology.core import guess_atom_element
from ..exceptions import NoDataError


Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/coordinates/PQR.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
.. _PDB: http://www.wwpdb.org/documentation/file-format
"""
import itertools
import numpy as np
import warnings

from ..lib import util
Expand Down
2 changes: 0 additions & 2 deletions package/MDAnalysis/coordinates/ParmEd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
import warnings
from ..converters.ParmEd import (ParmEdConverter, ParmEdReader,
get_indices_from_subset, MDA2PMD,)
Comment on lines -24 to -25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These MUST stay for compatibility reasons. The module will be removed in 3.0.0.

Just mark them to be ignored by the linter.



warnings.warn(
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/coordinates/TRR.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
MDAnalysis.coordinates.XDR: BaseReader/Writer for XDR based formats
"""
import errno
from . import base
from .XDR import XDRBaseReader, XDRBaseWriter
from ..lib.formats.libmdaxdr import TRRFile
from ..lib.mdamath import triclinic_vectors, triclinic_box
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/coordinates/TRZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from .timestep import Timestep
from ..lib import util
from ..lib.util import cached, store_init_arguments
from .core import triclinic_box, triclinic_vectors
from ..lib.mdamath import triclinic_box, triclinic_vectors


class TRZReader(base.ReaderBase):
Expand Down
3 changes: 1 addition & 2 deletions package/MDAnalysis/coordinates/TXYZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@
:inherited-members:

"""
import numpy as np
import os
import errno

from ..lib import util
from . import base
from ..lib.util import openany, cached, store_init_arguments
from ..lib.util import cached, store_init_arguments
from .timestep import Timestep

class TXYZReader(base.ReaderBase):
Expand Down
1 change: 0 additions & 1 deletion package/MDAnalysis/coordinates/XTC.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"""

import errno
from . import base
from .XDR import XDRBaseReader, XDRBaseWriter
from ..lib.formats.libmdaxdr import XTCFile
from ..lib.mdamath import triclinic_vectors, triclinic_box
Expand Down
Loading
Loading