Skip to content

Commit 328a778

Browse files
authored
gh-134357: Remove unused imports in tests (#134340)
1 parent 24a4715 commit 328a778

35 files changed

+26
-48
lines changed

Lib/test/.ruff.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,12 @@ extend-exclude = [
1919

2020
[lint]
2121
select = [
22+
"F401", # Unused import
2223
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
2324
]
25+
26+
[lint.per-file-ignores]
27+
"*/**/__main__.py" = ["F401"] # Unused import
28+
"test_import/*.py" = ["F401"] # Unused import
29+
"test_importlib/*.py" = ["F401"] # Unused import
30+
"typinganndata/partialexecution/*.py" = ["F401"] # Unused import

Lib/test/support/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ def __init__(self):
11011101
self.started = False
11021102

11031103
def start(self):
1104-
import warnings
11051104
try:
11061105
f = open(self.procfile, 'r')
11071106
except OSError as e:
@@ -2728,7 +2727,7 @@ def iter_builtin_types():
27282727
# Fall back to making a best-effort guess.
27292728
if hasattr(object, '__flags__'):
27302729
# Look for any type object with the Py_TPFLAGS_STATIC_BUILTIN flag set.
2731-
import datetime
2730+
import datetime # noqa: F401
27322731
seen = set()
27332732
for cls, subs in walk_class_hierarchy(object):
27342733
if cls in seen:

Lib/test/support/interpreters/channels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
# aliases:
88
from _interpchannels import (
9-
ChannelError, ChannelNotFoundError, ChannelClosedError,
10-
ChannelEmptyError, ChannelNotEmptyError,
9+
ChannelError, ChannelNotFoundError, ChannelClosedError, # noqa: F401
10+
ChannelEmptyError, ChannelNotEmptyError, # noqa: F401
1111
)
1212
from ._crossinterp import (
1313
UNBOUND_ERROR, UNBOUND_REMOVE,

Lib/test/support/interpreters/queues.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Cross-interpreter Queues High Level Module."""
22

3-
import pickle
43
import queue
54
import time
65
import weakref

Lib/test/test_capi/test_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import os
55
import sys
6-
import sysconfig
76
import types
87
import unittest
98
from test import support

Lib/test/test_codeccallbacks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import codecs
33
import html.entities
44
import itertools
5-
import re
65
import sys
76
import unicodedata
87
import unittest

Lib/test/test_crossinterp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import contextlib
2-
import importlib
3-
import importlib.util
42
import itertools
53
import sys
64
import types

Lib/test/test_ctypes/_support.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import ctypes
44
from _ctypes import Structure, Union, _Pointer, Array, _SimpleCData, CFuncPtr
55
import sys
6-
from test import support
76

87

98
_CData = Structure.__base__

Lib/test/test_ctypes/test_byteswap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import binascii
2-
import ctypes
32
import math
43
import struct
54
import sys

Lib/test/test_ctypes/test_generated_structs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"""
1111

1212
import unittest
13-
from test.support import import_helper, verbose
13+
from test.support import import_helper
1414
import re
1515
from dataclasses import dataclass
1616
from functools import cached_property

0 commit comments

Comments
 (0)