Skip to content

Commit 401d7a7

Browse files
authored
gh-102515: Remove unused imports in the Lib/ directory (#102516)
1 parent 7d801f2 commit 401d7a7

33 files changed

+8
-41
lines changed

Lib/_pylong.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
tricky or non-obvious code is not worth it. For people looking for
1313
maximum performance, they should use something like gmpy2."""
1414

15-
import sys
1615
import re
1716
import decimal
1817

Lib/concurrent/futures/process.py

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
from concurrent.futures import _base
5050
import queue
5151
import multiprocessing as mp
52+
# This import is required to load the multiprocessing.connection submodule
53+
# so that it can be accessed later as `mp.connection`
5254
import multiprocessing.connection
5355
from multiprocessing.queues import Queue
5456
import threading

Lib/dataclasses.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import types
55
import inspect
66
import keyword
7-
import builtins
87
import functools
98
import itertools
109
import abc

Lib/importlib/_abc.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Subset of importlib.abc used to reduce importlib.util imports."""
22
from . import _bootstrap
33
import abc
4-
import warnings
54

65

76
class Loader(metaclass=abc.ABCMeta):

Lib/sysconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import sys
55
import threading
6-
from os.path import pardir, realpath
6+
from os.path import realpath
77

88
__all__ = [
99
'get_config_h_filename',

Lib/test/_test_venv_multiprocessing.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import multiprocessing
22
import random
33
import sys
4-
import time
54

65
def fill_queue(queue, code):
76
queue.put(code)

Lib/test/fork_wait.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
active threads survive in the child after a fork(); this is an error.
1010
"""
1111

12-
import os, sys, time, unittest
12+
import os, time, unittest
1313
import threading
1414
from test import support
1515
from test.support import threading_helper

Lib/test/test__xxinterpchannels.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections import namedtuple
22
import contextlib
3-
import os
43
import sys
54
from textwrap import dedent
65
import threading

Lib/test/test__xxsubinterpreters.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from collections import namedtuple
21
import contextlib
32
import itertools
43
import os
54
import pickle
65
import sys
76
from textwrap import dedent
87
import threading
9-
import time
108
import unittest
119

1210
import _testcapi

Lib/test/test_asyncgen.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import types
33
import unittest
44
import contextlib
5-
import warnings
65

76
from test.support.import_helper import import_module
87
from test.support import gc_collect, requires_working_socket

Lib/test/test_asyncio/test_ssl.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import asyncio.sslproto
32
import contextlib
43
import gc
54
import logging

Lib/test/test_asyncio/test_subprocess.py

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

Lib/test/test_ctypes/test_callbacks.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import functools
32
import unittest
43
from test import support

Lib/test/test_dataclasses.py

-1
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,6 @@ def test_base_has_init(self):
22612261
class B:
22622262
def __init__(self):
22632263
self.z = 100
2264-
pass
22652264

22662265
# Make sure that declaring this class doesn't raise an error.
22672266
# The issue is that we can't override __init__ in our class,

Lib/test/test_enum.py

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from test import support
2121
from test.support import ALWAYS_EQ
2222
from test.support import threading_helper
23-
from textwrap import dedent
2423
from datetime import timedelta
2524

2625
python_version = sys.version_info[:2]
@@ -1187,7 +1186,6 @@ class MyEnum(HexInt, enum.Enum):
11871186
#
11881187
class SillyInt(HexInt):
11891188
__qualname__ = 'SillyInt'
1190-
pass
11911189
class MyOtherEnum(SillyInt, enum.Enum):
11921190
__qualname__ = 'MyOtherEnum'
11931191
D = 4

Lib/test/test_grammar.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from test.support import check_syntax_error
55
from test.support import import_helper
6-
from test.support.warnings_helper import check_syntax_warning
76
import inspect
87
import unittest
98
import sys
@@ -15,7 +14,6 @@
1514
# with import machinery
1615
import test.ann_module as ann_module
1716
import typing
18-
from collections import ChainMap
1917
from test import ann_module2
2018
import test
2119

Lib/test/test_hashlib.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from test.support import os_helper
2323
from test.support import requires_resource
2424
from test.support import threading_helper
25-
from test.support import warnings_helper
2625
from http.client import HTTPException
2726

2827

Lib/test/test_httplib.py

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import re
99
import socket
1010
import threading
11-
import warnings
1211

1312
import unittest
1413
from unittest import mock
@@ -17,7 +16,6 @@
1716
from test import support
1817
from test.support import os_helper
1918
from test.support import socket_helper
20-
from test.support import warnings_helper
2119

2220
support.requires_working_socket(module=True)
2321

Lib/test/test_imaplib.py

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from test.support import verbose, run_with_tz, run_with_locale, cpython_only
1414
from test.support import hashlib_helper
1515
from test.support import threading_helper
16-
from test.support import warnings_helper
1716
import unittest
1817
from unittest import mock
1918
from datetime import datetime, timezone, timedelta
@@ -751,7 +750,6 @@ class NonUTF8Server(SimpleIMAPHandler):
751750
typ, data = client.login('user', 'pass')
752751
self.assertEqual(typ, 'OK')
753752
client.enable('UTF8=ACCEPT')
754-
pass
755753

756754
@threading_helper.reap_threads
757755
def test_enable_UTF8_True_append(self):

Lib/test/test_isinstance.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# testing of error conditions uncovered when using extension types.
44

55
import unittest
6-
import sys
76
import typing
87
from test import support
98

Lib/test/test_minidom.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from test import support
77
import unittest
88

9-
import pyexpat
109
import xml.dom.minidom
1110

1211
from xml.dom.minidom import parse, Attr, Node, Document, parseString

Lib/test/test_peg_generator/test_c_parser.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
generate_parser_c_extension,
2525
generate_c_parser_source,
2626
)
27-
from pegen.ast_dump import ast_dump
2827

2928

3029
TEST_TEMPLATE = """

Lib/test/test_shlex.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import shlex
44
import string
55
import unittest
6-
from unittest import mock
76

87

98
# The original test data set was from shellwords, by Hartmut Goebel.

Lib/test/test_sys_setprofile.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pprint
33
import sys
44
import unittest
5-
from test import support
65

76

87
class TestGetProfile(unittest.TestCase):

Lib/test/test_sys_settrace.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from test import support
44
import unittest
5-
from unittest.mock import MagicMock
65
import sys
76
import difflib
87
import gc

Lib/test/test_tkinter/test_widgets.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
AbstractDefaultRootTest)
1010
from test.test_tkinter.widget_tests import (
1111
add_standard_options,
12-
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
13-
setUpModule)
12+
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
1413

1514
requires('gui')
1615

Lib/test/test_tools/test_sundry.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
import os
9-
import sys
109
import unittest
1110
from test.support import import_helper
1211

Lib/test/test_traceback.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77
import types
88
import inspect
9-
import importlib
109
import builtins
1110
import unittest
1211
import re

Lib/test/test_ttk/test_widgets.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from test.test_tkinter.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
99
simulate_mouse_click, AbstractDefaultRootTest)
1010
from test.test_tkinter.widget_tests import (add_standard_options,
11-
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
12-
setUpModule)
11+
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
1312

1413
requires('gui')
1514

@@ -50,7 +49,6 @@ def test_configure_style(self):
5049
widget2 = self.create(class_='Foo')
5150
self.assertEqual(widget2['class'], 'Foo')
5251
# XXX
53-
pass
5452

5553

5654
class WidgetTest(AbstractTkTest, unittest.TestCase):

Lib/test/test_unicodedata.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import unicodedata
1313
import unittest
1414
from test.support import (open_urlresource, requires_resource, script_helper,
15-
cpython_only, check_disallow_instantiation,
16-
ResourceDenied)
15+
cpython_only, check_disallow_instantiation)
1716

1817

1918
class UnicodeMethodsTest(unittest.TestCase):

Lib/test/test_unittest/test_loader.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import functools
22
import sys
33
import types
4-
import warnings
54

65
import unittest
76

Lib/test/test_wmi.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Test the internal _wmi module on Windows
22
# This is used by the platform module, and potentially others
33

4-
import sys
54
import unittest
65
from test.support import import_helper, requires_resource
76

Lib/test/test_zipfile64.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'test requires loads of disk-space bytes and a long time to run'
1212
)
1313

14-
import zipfile, os, unittest
14+
import zipfile, unittest
1515
import time
1616
import sys
1717

0 commit comments

Comments
 (0)