Skip to content

Remove unused imports #9191

@jnothman

Description

@jnothman

pyflakes reports that we have many unused imports and some variables. This is probably a result of us only running flake8 on diffs. Unlike pep8 issues, I think these should be fixed (and # noqa used where we resolve not to fix):

sklearn/__check_build/__init__.py:44: '._check_build.check_build' imported but unused
sklearn/cluster/tests/test_k_means.py:30: 'sklearn.exceptions.DataConversionWarning' imported but unused
sklearn/cluster/tests/test_spectral.py:68: 'pyamg.smoothed_aggregation_solver' imported but unused
sklearn/cross_decomposition/__init__.py:1: 'from .pls_ import *' used; unable to detect undefined names
sklearn/cross_decomposition/__init__.py:1: '.pls_.*' imported but unused
sklearn/cross_decomposition/__init__.py:2: 'from .cca_ import *' used; unable to detect undefined names
sklearn/cross_decomposition/__init__.py:2: '.cca_.*' imported but unused
sklearn/datasets/tests/test_base.py:161: 'scipy.misc.pilutil.imread' imported but unused
sklearn/ensemble/bagging.py:581: local variable 'classes_' is assigned to but never used
sklearn/ensemble/tests/test_gradient_boosting_loss_functions.py:158: local variable 'X' is assigned to but never used
sklearn/ensemble/tests/test_weight_boosting.py:311: 'sklearn.linear_model.LogisticRegression' imported but unused
sklearn/feature_selection/tests/test_mutual_info.py:7: 'sklearn.utils.testing.assert_allclose' imported but unused
sklearn/linear_model/__init__.py:22: '.sgd_fast.Huber' imported but unused
sklearn/linear_model/huber.py:51: local variable 'X_is_sparse' is assigned to but never used
sklearn/linear_model/tests/test_coordinate_descent.py:5: 'sys.version_info' imported but unused
sklearn/linear_model/tests/test_coordinate_descent.py:16: 'sklearn.utils.testing.SkipTest' imported but unused
sklearn/linear_model/tests/test_huber.py:122: local variable 'rng' is assigned to but never used
sklearn/linear_model/tests/test_ransac.py:4: redefinition of unused 'sparse' from line 1
sklearn/manifold/tests/test_spectral_embedding.py:165: 'pyamg.smoothed_aggregation_solver' imported but unused
sklearn/metrics/__init__.py:20: '.classification.cohen_kappa_score' imported but unused
sklearn/metrics/__init__.py:44: '.cluster.fowlkes_mallows_score' imported but unused
sklearn/metrics/__init__.py:47: '.cluster.calinski_harabaz_score' imported but unused
sklearn/metrics/tests/test_classification.py:14: 'sklearn.utils.fixes.np_version' imported but unused
sklearn/preprocessing/tests/test_function_transformer.py:3: 'sklearn.utils.testing' imported but unused
sklearn/svm/bounds.py:5: 'warnings.warn' imported but unused
sklearn/svm/tests/test_bounds.py:1: 'warnings' imported but unused
sklearn/svm/tests/test_svm.py:511: undefined name 'unicode'
sklearn/tests/test_common.py:99: undefined name 'execfile'
sklearn/tests/test_grid_search.py:47: 'sklearn.exceptions.ChangedBehaviorWarning' imported but unused
sklearn/tests/test_init.py:10: 'from sklearn import *' used; unable to detect undefined names
sklearn/tests/test_init.py:10: 'sklearn.*' imported but unused
sklearn/tests/test_random_projection.py:269: import 'SparseRandomProjection' from line 11 shadowed by loop variable
sklearn/tree/tree.py:38: '..exceptions.NotFittedError' imported but unused
sklearn/utils/_scipy_sparse_lsqr_backport.py:284: local variable 'nstop' is assigned to but never used
sklearn/utils/_scipy_sparse_lsqr_backport.py:303: local variable '__xm' is assigned to but never used
sklearn/utils/_scipy_sparse_lsqr_backport.py:304: local variable '__xn' is assigned to but never used
sklearn/utils/fixes.py:144: 'scipy.sparse.linalg.lsqr as sparse_lsqr' imported but unused
sklearn/utils/fixes.py:150: 'scipy.misc.logsumexp' imported but unused
sklearn/utils/fixes.py:150: 'scipy.misc.comb' imported but unused
sklearn/utils/fixes.py:195: 'numpy.ma.MaskedArray' imported but unused
sklearn/utils/graph.py:13: 'numpy as np' imported but unused
sklearn/utils/graph.py:16: '.validation.check_array' imported but unused
sklearn/utils/graph.py:17: '.graph_shortest_path.graph_shortest_path' imported but unused
sklearn/utils/tests/test_estimator_checks.py:144: 'pandas.Series' imported but unused
sklearn/utils/tests/test_extmath.py:19: 'sklearn.utils.testing.assert_raises' imported but unused

We should also consider running pyflakes on the entirety of changed files in CI even if we only run pep8 on diffs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Build / CIEasyWell-defined and straightforward way to resolve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions