diff options
author | Mike Taves <mwtoews@gmail.com> | 2020-02-05 08:21:51 +1300 |
---|---|---|
committer | Mike Taves <mwtoews@gmail.com> | 2020-02-06 22:16:23 +1300 |
commit | 07bf33fbf5be8143aab037dc65aba3086f8badf6 (patch) | |
tree | 8f48992ca38bafe589ed331f54c43106ba23902d /numpy | |
parent | a9bc5db4671c6c702e3a8a35fbf31b8d3225fad2 (diff) | |
download | numpy-07bf33fbf5be8143aab037dc65aba3086f8badf6.tar.gz |
MAINT: cleanup unused imports; avoid redefinition of imports
* Cleanup unused imports (F401) of mostly standard Python modules,
or some internal but unlikely referenced modules
* Where internal imports are potentially used, mark with noqa
* Avoid redefinition of imports (F811)
Diffstat (limited to 'numpy')
32 files changed, 24 insertions, 51 deletions
diff --git a/numpy/core/_type_aliases.py b/numpy/core/_type_aliases.py index dfb70430f..c26431443 100644 --- a/numpy/core/_type_aliases.py +++ b/numpy/core/_type_aliases.py @@ -23,7 +23,6 @@ and sometimes other mappings too. """ import warnings -import sys from numpy.compat import unicode from numpy._globals import VisibleDeprecationWarning diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py index c32cf3e44..04c023675 100644 --- a/numpy/core/code_generators/generate_ufunc_api.py +++ b/numpy/core/code_generators/generate_ufunc_api.py @@ -3,8 +3,7 @@ import genapi import numpy_api -from genapi import \ - TypeApi, GlobalVarApi, FunctionApi, BoolValuesApi +from genapi import TypeApi, FunctionApi h_template = r""" #ifdef _UMATHMODULE diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index 8f92a4f71..6d49b9055 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -4,8 +4,7 @@ import operator import types from . import numeric as _nx -from .numeric import (result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, - TooHardError, asanyarray, ndim) +from .numeric import result_type, NaN, asanyarray, ndim from numpy.core.multiarray import add_docstring from numpy.core import overrides diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 66c1b782e..ec96467c6 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -392,7 +392,7 @@ def visibility_define(config): def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration, dot_join - from numpy.distutils.system_info import get_info, dict_append + from numpy.distutils.system_info import get_info config = Configuration('core', parent_package, top_path) local_dir = config.local_path diff --git a/numpy/core/umath.py b/numpy/core/umath.py index c3cebb03f..d2f769505 100644 --- a/numpy/core/umath.py +++ b/numpy/core/umath.py @@ -8,9 +8,7 @@ by importing from the extension module. from . import _multiarray_umath from ._multiarray_umath import * # noqa: F403 -from ._multiarray_umath import ( - _UFUNC_API, _add_newdoc_ufunc, _ones_like - ) +from ._multiarray_umath import _UFUNC_API, _add_newdoc_ufunc __all__ = [ '_UFUNC_API', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG', diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py index 1b4666888..d679b2d03 100644 --- a/numpy/distutils/command/build_clib.py +++ b/numpy/distutils/command/build_clib.py @@ -9,9 +9,10 @@ from distutils.errors import DistutilsSetupError, DistutilsError, \ from numpy.distutils import log from distutils.dep_util import newer_group -from numpy.distutils.misc_util import filter_sources, has_f_sources,\ - has_cxx_sources, all_strings, get_lib_source_files, is_sequence, \ - get_numpy_include_dirs +from numpy.distutils.misc_util import ( + filter_sources, get_lib_source_files, get_numpy_include_dirs, + has_cxx_sources, has_f_sources, is_sequence +) # Fix Python distutils bug sf #1718574: _l = old_build_clib.user_options diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index a0da83ff4..0e07ba9cf 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -13,11 +13,11 @@ from distutils.file_util import copy_file from numpy.distutils import log from numpy.distutils.exec_command import filepath_from_subprocess_output -from numpy.distutils.system_info import combine_paths, system_info -from numpy.distutils.misc_util import filter_sources, has_f_sources, \ - has_cxx_sources, get_ext_source_files, \ - get_numpy_include_dirs, is_sequence, get_build_architecture, \ - msvc_version +from numpy.distutils.system_info import combine_paths +from numpy.distutils.misc_util import ( + filter_sources, get_ext_source_files, get_numpy_include_dirs, + has_cxx_sources, has_f_sources, is_sequence +) from numpy.distutils.command.config_compiler import show_fortran_compilers diff --git a/numpy/distutils/core.py b/numpy/distutils/core.py index d3461aa49..d5551f349 100644 --- a/numpy/distutils/core.py +++ b/numpy/distutils/core.py @@ -1,5 +1,5 @@ import sys -from distutils.core import Distribution, setup +from distutils.core import Distribution if 'setuptools' in sys.modules: have_setuptools = True @@ -25,7 +25,7 @@ from numpy.distutils.command import config, config_compiler, \ build, build_py, build_ext, build_clib, build_src, build_scripts, \ sdist, install_data, install_headers, install, bdist_rpm, \ install_clib -from numpy.distutils.misc_util import get_data_files, is_sequence, is_string +from numpy.distutils.misc_util import is_sequence, is_string numpy_cmdclass = {'build': build.build, 'build_src': build_src.build_src, diff --git a/numpy/distutils/extension.py b/numpy/distutils/extension.py index 704f1e7aa..67114ef2e 100644 --- a/numpy/distutils/extension.py +++ b/numpy/distutils/extension.py @@ -6,7 +6,6 @@ modules in setup scripts. Overridden to support f2py. """ -import sys import re from distutils.extension import Extension as old_Extension diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index a88b0d713..1c3069363 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -19,7 +19,6 @@ __all__ = ['FCompiler', 'new_fcompiler', 'show_fcompilers', import os import sys import re -import types from numpy.compat import open_latin1 diff --git a/numpy/distutils/fcompiler/environment.py b/numpy/distutils/fcompiler/environment.py index ae5fc404a..21a5be003 100644 --- a/numpy/distutils/fcompiler/environment.py +++ b/numpy/distutils/fcompiler/environment.py @@ -1,5 +1,4 @@ import os -import warnings from distutils.dist import Distribution __metaclass__ = type diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 128e54db3..8d69f6ba6 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -10,7 +10,6 @@ import subprocess from subprocess import Popen, PIPE, STDOUT from numpy.distutils.exec_command import filepath_from_subprocess_output from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.system_info import system_info compilers = ['GnuFCompiler', 'Gnu95FCompiler'] diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py index f3f96bbf2..eb628cb63 100644 --- a/numpy/distutils/fcompiler/pg.py +++ b/numpy/distutils/fcompiler/pg.py @@ -1,7 +1,7 @@ # http://www.pgroup.com import sys -from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file +from numpy.distutils.fcompiler import FCompiler from sys import platform from os.path import join, dirname, normpath diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index 475f73718..031b7c95f 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -14,7 +14,7 @@ import re import textwrap # Overwrite certain distutils.ccompiler functions: -import numpy.distutils.ccompiler +import numpy.distutils.ccompiler # noqa: F401 from numpy.distutils import log # NT stuff # 1. Make sure libpython<version>.a exists for gcc. If not, build it. @@ -26,8 +26,7 @@ import distutils.cygwinccompiler from distutils.version import StrictVersion from distutils.unixccompiler import UnixCCompiler from distutils.msvccompiler import get_build_version as get_build_msvc_version -from distutils.errors import (DistutilsExecError, CompileError, - UnknownFileError) +from distutils.errors import UnknownFileError from numpy.distutils.misc_util import (msvc_runtime_library, msvc_runtime_version, msvc_runtime_major, diff --git a/numpy/distutils/npy_pkg_config.py b/numpy/distutils/npy_pkg_config.py index 26a0437fb..951ce5fb8 100644 --- a/numpy/distutils/npy_pkg_config.py +++ b/numpy/distutils/npy_pkg_config.py @@ -375,7 +375,6 @@ def read_config(pkgname, dirs=None): # pkg-config simple emulator - useful for debugging, and maybe later to query # the system if __name__ == '__main__': - import sys from optparse import OptionParser import glob diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index ae3f1fa2a..11d7c5a0e 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -177,7 +177,7 @@ from distutils.util import get_platform from numpy.distutils.exec_command import ( find_executable, filepath_from_subprocess_output, - get_pythonexe) + ) from numpy.distutils.misc_util import (is_sequence, is_string, get_shared_lib_extension) from numpy.distutils.command.config import config as cmd_config diff --git a/numpy/distutils/tests/test_fcompiler.py b/numpy/distutils/tests/test_fcompiler.py index c559becf8..dd97f1e72 100644 --- a/numpy/distutils/tests/test_fcompiler.py +++ b/numpy/distutils/tests/test_fcompiler.py @@ -1,6 +1,4 @@ -import pytest - -from numpy.testing import assert_, suppress_warnings +from numpy.testing import assert_ import numpy.distutils.fcompiler customizable_flags = [ diff --git a/numpy/distutils/tests/test_shell_utils.py b/numpy/distutils/tests/test_shell_utils.py index 754609a5d..32bd283e5 100644 --- a/numpy/distutils/tests/test_shell_utils.py +++ b/numpy/distutils/tests/test_shell_utils.py @@ -1,6 +1,5 @@ import pytest import subprocess -import os import json import sys diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py index 65ad4da72..b74874075 100644 --- a/numpy/f2py/__init__.py +++ b/numpy/f2py/__init__.py @@ -8,8 +8,6 @@ import sys import subprocess import os -import numpy as np - from . import f2py2e from . import f2py_testing from . import diagnose diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index bbfcf1a24..c362fb008 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -19,7 +19,6 @@ f2py_version = __version__.version import copy import re import os -import sys from .crackfortran import markoutercomma from . import cb_rules diff --git a/numpy/f2py/tests/test_crackfortran.py b/numpy/f2py/tests/test_crackfortran.py index 796965e6f..18a1474b0 100644 --- a/numpy/f2py/tests/test_crackfortran.py +++ b/numpy/f2py/tests/test_crackfortran.py @@ -1,5 +1,3 @@ -import pytest - import numpy as np from numpy.testing import assert_array_equal from . import util diff --git a/numpy/f2py/tests/test_quoted_character.py b/numpy/f2py/tests/test_quoted_character.py index d89ef1385..20c77666c 100644 --- a/numpy/f2py/tests/test_quoted_character.py +++ b/numpy/f2py/tests/test_quoted_character.py @@ -2,7 +2,6 @@ """ import sys -from importlib import import_module import pytest from numpy.testing import assert_equal diff --git a/numpy/fft/tests/test_helper.py b/numpy/fft/tests/test_helper.py index 2b457271b..68f5990af 100644 --- a/numpy/fft/tests/test_helper.py +++ b/numpy/fft/tests/test_helper.py @@ -4,7 +4,7 @@ Copied from fftpack.helper by Pearu Peterson, October 2005 """ import numpy as np -from numpy.testing import assert_array_almost_equal, assert_equal +from numpy.testing import assert_array_almost_equal from numpy import fft, pi diff --git a/numpy/fft/tests/test_pocketfft.py b/numpy/fft/tests/test_pocketfft.py index 14f92c081..7c3db0485 100644 --- a/numpy/fft/tests/test_pocketfft.py +++ b/numpy/fft/tests/test_pocketfft.py @@ -5,7 +5,6 @@ from numpy.testing import ( assert_array_equal, assert_raises, assert_allclose ) import threading -import sys import queue diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index 76cc306b7..f5d0cc217 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -35,7 +35,6 @@ Example:: """ import os -import sys import shutil import io from contextlib import closing diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index a154cbbc8..cd93a9a14 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -13,7 +13,6 @@ and the masking of individual fields. # first place, and then rename the invalid fields with a trailing # underscore. Maybe we could just overload the parser function ? -import sys import warnings import numpy as np diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py index b0d4c60fe..64b8803dd 100644 --- a/numpy/random/tests/test_extending.py +++ b/numpy/random/tests/test_extending.py @@ -50,8 +50,8 @@ def test_cython(tmp_path): @pytest.mark.skipif(numba is None or cffi is None, reason="requires numba and cffi") def test_numba(): - from numpy.random._examples.numba import extending + from numpy.random._examples.numba import extending # noqa: F401 @pytest.mark.skipif(cffi is None, reason="requires cffi") def test_cffi(): - from numpy.random._examples.cffi import extending + from numpy.random._examples.cffi import extending # noqa: F401 diff --git a/numpy/testing/_private/parameterized.py b/numpy/testing/_private/parameterized.py index 382585345..3bd8ede91 100644 --- a/numpy/testing/_private/parameterized.py +++ b/numpy/testing/_private/parameterized.py @@ -31,7 +31,6 @@ either expressed or implied, of David Wolever. """ import re -import sys import inspect import warnings from functools import wraps diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index 913c67fc6..b899e94f4 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -2,7 +2,6 @@ import warnings import sys import os import itertools -import textwrap import pytest import weakref diff --git a/numpy/tests/test_reloading.py b/numpy/tests/test_reloading.py index a6d2e62a9..860832be8 100644 --- a/numpy/tests/test_reloading.py +++ b/numpy/tests/test_reloading.py @@ -1,5 +1,3 @@ -import sys - from numpy.testing import assert_raises, assert_, assert_equal from numpy.compat import pickle diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py index 658606f82..a0f2ba70a 100644 --- a/numpy/tests/test_scripts.py +++ b/numpy/tests/test_scripts.py @@ -9,7 +9,7 @@ from os.path import join as pathjoin, isfile, dirname import subprocess import numpy as np -from numpy.testing import assert_, assert_equal +from numpy.testing import assert_equal is_inplace = isfile(pathjoin(dirname(np.__file__), '..', 'setup.py')) diff --git a/numpy/tests/test_warnings.py b/numpy/tests/test_warnings.py index c4c206542..d7a6d880c 100644 --- a/numpy/tests/test_warnings.py +++ b/numpy/tests/test_warnings.py @@ -2,7 +2,6 @@ Tests which scan for certain occurrences in the code, they may not find all of these occurrences but should catch almost all. """ -import sys import pytest from pathlib import Path |