Skip to content

Commit c0e9b53

Browse files
MAINT: apply ruff/Pycodestyle rule F401
F401 imported but unused I have left out *.pyi files. Still lots of occurrences to examine. Co-authored-by: Robert Kern <[email protected]>
1 parent 392baea commit c0e9b53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10
-72
lines changed

Diff for: benchmarks/benchmarks/common.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import random
3-
import os
43
from functools import lru_cache
54
from pathlib import Path
65

Diff for: doc/neps/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# add these directories to sys.path here. If the directory is relative to the
1616
# documentation root, use os.path.abspath to make it absolute, like shown here.
1717
#
18-
import os
1918
from datetime import datetime
2019
# import sys
2120
# sys.path.insert(0, os.path.abspath('.'))

Diff for: doc/preprocess.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env python3
2-
import subprocess
32
import os
4-
import sys
53
from string import Template
64

75
def main():

Diff for: doc/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def linkcode_resolve(domain, info):
575575
numpy.__version__, fn, linespec)
576576

577577
from pygments.lexers import CLexer
578-
from pygments.lexer import inherit, bygroups
578+
from pygments.lexer import inherit
579579
from pygments.token import Comment
580580

581581
class NumPyLexer(CLexer):

Diff for: doc/source/reference/simd/gen_features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Generate CPU features tables from CCompilerOpt
33
"""
4-
from os import sys, path
4+
from os import path
55
from numpy.distutils.ccompiler_opt import CCompilerOpt
66

77
class FakeCCompilerOpt(CCompilerOpt):

Diff for: numpy/_build_utils/gcc_build_bitness.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import re
6-
from subprocess import run, PIPE
6+
from subprocess import run
77

88

99
def main():

Diff for: numpy/_build_utils/process_src_template.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
import sys
32
import os
43
import argparse
54
import importlib.util

Diff for: numpy/_core/_ufunc_config.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
This provides helpers which wrap `_get_extobj_dict` and `_make_extobj`, and
55
`_extobj_contextvar` from umath.
66
"""
7-
import collections.abc
87
import contextlib
98
import contextvars
109
import functools

Diff for: numpy/_core/code_generators/generate_umath.py

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"""
66
import os
77
import re
8-
import struct
9-
import sys
108
import textwrap
119
import argparse
1210

Diff for: numpy/_core/numerictypes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
from . import multiarray as ma
8383
from .multiarray import (
84-
ndarray, array, dtype, datetime_data, datetime_as_string,
84+
ndarray, dtype, datetime_data, datetime_as_string,
8585
busday_offset, busday_count, is_busday, busdaycalendar
8686
)
8787
from .._utils import set_module
@@ -95,7 +95,7 @@
9595

9696
# we don't need all these imports, but we need to keep them for compatibility
9797
# for users using np._core.numerictypes.UPPER_TABLE
98-
from ._string_helpers import (
98+
from ._string_helpers import ( # noqa: F401
9999
english_lower, english_upper, english_capitalize, LOWER_TABLE, UPPER_TABLE
100100
)
101101

@@ -106,7 +106,7 @@
106106

107107
# we don't export these for import *, but we do want them accessible
108108
# as numerictypes.bool, etc.
109-
from builtins import bool, int, float, complex, object, str, bytes # noqa: UP029
109+
from builtins import bool, int, float, complex, object, str, bytes # noqa: F401, UP029
110110

111111

112112
# We use this later

Diff for: numpy/_core/overrides.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Implementation of __array_function__ overrides from NEP-18."""
22
import collections
33
import functools
4-
import os
54

65
from .._utils import set_module
76
from .._utils._inspect import getargspec

Diff for: numpy/_core/shape_base.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import functools
55
import itertools
66
import operator
7-
import warnings
87

98
from . import numeric as _nx
109
from . import overrides

Diff for: numpy/_core/tests/test_arraymethod.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from __future__ import annotations
77

8-
import sys
98
import types
109
from typing import Any
1110

Diff for: numpy/_core/tests/test_custom_dtypes.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from tempfile import NamedTemporaryFile
32

43
import pytest

Diff for: numpy/_core/tests/test_cython.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from datetime import datetime
22
import os
3-
import shutil
43
import subprocess
54
import sys
6-
import time
75
import pytest
86

97
import numpy as np

Diff for: numpy/_core/tests/test_deprecations.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
to document how deprecations should eventually be turned into errors.
44
55
"""
6-
import datetime
7-
import operator
86
import warnings
97
import pytest
108
import tempfile
119
import re
12-
import sys
1310

1411
import numpy as np
1512
from numpy.testing import (

Diff for: numpy/_core/tests/test_einsum.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import itertools
2-
import sys
3-
import platform
42

53
import pytest
64

Diff for: numpy/_core/tests/test_limited_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import shutil
32
import subprocess
43
import sys
54
import sysconfig

Diff for: numpy/_core/tests/test_mem_policy.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import sys
55
import threading
6-
import warnings
76

87
import pytest
98

Diff for: numpy/_core/tests/test_unicode.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21

32
import numpy as np
43
from numpy.testing import assert_, assert_equal, assert_array_equal

Diff for: numpy/f2py/_backends/_meson.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from string import Template
1313
from itertools import chain
1414

15-
import warnings
1615

1716

1817
class MesonTemplate:

Diff for: numpy/f2py/auxfuncs.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import re
1414
import types
1515
from functools import reduce
16-
from copy import deepcopy
1716

1817
from . import __version__
1918
from . import cfuncs

Diff for: numpy/f2py/f2py2e.py

-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import os
1616
import pprint
1717
import re
18-
from pathlib import Path
19-
from itertools import dropwhile
2018
import argparse
21-
import copy
2219

2320
from . import crackfortran
2421
from . import rules

Diff for: numpy/f2py/tests/test_abstract_interface.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from pathlib import Path
21
import pytest
3-
import textwrap
42
from . import util
53
from numpy.f2py import crackfortran
64
from numpy.testing import IS_WASM

Diff for: numpy/f2py/tests/test_array_from_pyobj.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import sys
32
import copy
43
import platform
@@ -7,7 +6,6 @@
76

87
import numpy as np
98

10-
from numpy.testing import assert_, assert_equal
119
from numpy._core._type_aliases import c_names_dict as _c_names_dict
1210
from . import util
1311

Diff for: numpy/f2py/tests/test_crackfortran.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import importlib
2-
import codecs
32
import time
4-
import unicodedata
53
import pytest
64
import numpy as np
75
from numpy.f2py.crackfortran import markinnerspaces, nameargspattern

Diff for: numpy/f2py/tests/test_data.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import pytest
32
import numpy as np
43

Diff for: numpy/f2py/tests/test_kind.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
import os
32
import pytest
43
import platform
54

Diff for: numpy/f2py/tests/test_mixed.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import textwrap
32
import pytest
43

Diff for: numpy/f2py/tests/test_parameter.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import pytest
32

43
import numpy as np

Diff for: numpy/f2py/tests/test_size.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import pytest
32
import numpy as np
43

Diff for: numpy/f2py/tests/test_string.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
21
import pytest
3-
import textwrap
42
import numpy as np
53
from . import util
64

Diff for: numpy/f2py/tests/test_value_attrspec.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import pytest
32

43
from . import util

Diff for: numpy/f2py/tests/util.py

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import tempfile
1414
import shutil
1515
import atexit
16-
import textwrap
17-
import re
1816
import pytest
1917
import contextlib
2018
import numpy

Diff for: numpy/lib/_npyio_impl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import weakref
1010
import contextlib
1111
import operator
12-
from operator import itemgetter, index as opindex, methodcaller
12+
from operator import itemgetter
1313
from collections.abc import Mapping
1414
import pickle
1515

Diff for: numpy/lib/_ufunclike_impl.py

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import numpy._core.numeric as nx
99
from numpy._core.overrides import array_function_dispatch
10-
import warnings
11-
import functools
1210

1311

1412
def _dispatcher(x, out=None):

Diff for: numpy/lib/_utils_impl.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sys
33
import textwrap
44
import types
5-
import re
65
import warnings
76
import functools
87
import platform

Diff for: numpy/lib/tests/test_histograms.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
assert_array_almost_equal, assert_raises, assert_allclose,
77
assert_array_max_ulp, assert_raises_regex, suppress_warnings,
88
)
9-
from numpy.testing._private.utils import requires_memory
109
import pytest
1110

1211

Diff for: numpy/lib/tests/test_recfunctions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21

32
import numpy as np
43
import numpy.ma as ma

Diff for: numpy/lib/tests/test_regression.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
assert_, assert_equal, assert_array_equal, assert_array_almost_equal,
66
assert_raises, _assert_valid_refcount,
77
)
8-
import pytest
98

109

1110
class TestRegression:

Diff for: numpy/linalg/tests/test_regression.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
""" Test functions for linalg module
22
"""
3-
import warnings
43

54
import pytest
65

Diff for: numpy/random/tests/test_extending.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
from importlib.util import spec_from_file_location, module_from_spec
22
import os
3-
import pathlib
43
import pytest
54
import shutil
65
import subprocess
76
import sys
87
import sysconfig
9-
import textwrap
108
import warnings
119

1210
import numpy as np

Diff for: numpy/testing/overrides.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_overridable_numpy_array_functions():
6363
"""
6464
# 'import numpy' doesn't import recfunctions, so make sure it's imported
6565
# so ufuncs defined there show up in the ufunc listing
66-
from numpy.lib import recfunctions
66+
from numpy.lib import recfunctions # noqa: F401
6767
return _array_functions.copy()
6868

6969
def allows_array_function_override(func):

Diff for: numpy/tests/test_lazyloading.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
import importlib
32
from importlib.util import LazyLoader, find_spec, module_from_spec
43
import pytest
54

@@ -27,7 +26,7 @@ def test_lazy_load():
2726
np = module
2827

2928
# test a subpackage import
30-
from numpy.lib import recfunctions
29+
from numpy.lib import recfunctions # noqa: F401
3130

3231
# test triggering the import of the package
3332
np.ndarray

Diff for: numpy/tests/test_numpy_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
import numpy as np
55
import pytest
6-
from unittest.mock import Mock, patch
6+
from unittest.mock import patch
77

88
pytestmark = pytest.mark.skipif(
99
not hasattr(np.__config__, "_built_with_meson"),

Diff for: numpy/typing/tests/data/pass/scalars.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import datetime as dt
32

43
import pytest

Diff for: pavement.py

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
the same underlying python for egg install in venv and for bdist_mpkg
2424
"""
2525
import os
26-
import sys
27-
import shutil
2826
import hashlib
2927
import textwrap
3028

0 commit comments

Comments
 (0)