[Python-checkins] gh-102515: Remove unused imports in the `Lib/` directory (#102516)
pablogsal
webhook-mailer at python.org
Wed Mar 8 06:45:45 EST 2023
https://github.com/python/cpython/commit/401d7a7f009ca2e282b1a0d1b880dc602afd39dc
commit: 401d7a7f009ca2e282b1a0d1b880dc602afd39dc
branch: main
author: Alex Waygood <Alex.Waygood at Gmail.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2023-03-08T11:45:38Z
summary:
gh-102515: Remove unused imports in the `Lib/` directory (#102516)
files:
M Lib/_pylong.py
M Lib/concurrent/futures/process.py
M Lib/dataclasses.py
M Lib/importlib/_abc.py
M Lib/sysconfig.py
M Lib/test/_test_venv_multiprocessing.py
M Lib/test/fork_wait.py
M Lib/test/test__xxinterpchannels.py
M Lib/test/test__xxsubinterpreters.py
M Lib/test/test_asyncgen.py
M Lib/test/test_asyncio/test_ssl.py
M Lib/test/test_asyncio/test_subprocess.py
M Lib/test/test_ctypes/test_callbacks.py
M Lib/test/test_dataclasses.py
M Lib/test/test_enum.py
M Lib/test/test_grammar.py
M Lib/test/test_hashlib.py
M Lib/test/test_httplib.py
M Lib/test/test_imaplib.py
M Lib/test/test_isinstance.py
M Lib/test/test_minidom.py
M Lib/test/test_peg_generator/test_c_parser.py
M Lib/test/test_shlex.py
M Lib/test/test_sys_setprofile.py
M Lib/test/test_sys_settrace.py
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_tools/test_sundry.py
M Lib/test/test_traceback.py
M Lib/test/test_ttk/test_widgets.py
M Lib/test/test_unicodedata.py
M Lib/test/test_unittest/test_loader.py
M Lib/test/test_wmi.py
M Lib/test/test_zipfile64.py
diff --git a/Lib/_pylong.py b/Lib/_pylong.py
index d14c1d938363..936346e187ff 100644
--- a/Lib/_pylong.py
+++ b/Lib/_pylong.py
@@ -12,7 +12,6 @@
tricky or non-obvious code is not worth it. For people looking for
maximum performance, they should use something like gmpy2."""
-import sys
import re
import decimal
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py
index bee162430a6f..3a8637b6fa1b 100644
--- a/Lib/concurrent/futures/process.py
+++ b/Lib/concurrent/futures/process.py
@@ -49,6 +49,8 @@
from concurrent.futures import _base
import queue
import multiprocessing as mp
+# This import is required to load the multiprocessing.connection submodule
+# so that it can be accessed later as `mp.connection`
import multiprocessing.connection
from multiprocessing.queues import Queue
import threading
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 5c0257eba186..8bc8594d674b 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -4,7 +4,6 @@
import types
import inspect
import keyword
-import builtins
import functools
import itertools
import abc
diff --git a/Lib/importlib/_abc.py b/Lib/importlib/_abc.py
index 083205638965..693b46611263 100644
--- a/Lib/importlib/_abc.py
+++ b/Lib/importlib/_abc.py
@@ -1,7 +1,6 @@
"""Subset of importlib.abc used to reduce importlib.util imports."""
from . import _bootstrap
import abc
-import warnings
class Loader(metaclass=abc.ABCMeta):
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index c61100a6da85..122d441bd19f 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -3,7 +3,7 @@
import os
import sys
import threading
-from os.path import pardir, realpath
+from os.path import realpath
__all__ = [
'get_config_h_filename',
diff --git a/Lib/test/_test_venv_multiprocessing.py b/Lib/test/_test_venv_multiprocessing.py
index 044a0c6cd3f5..ad985dd8d56b 100644
--- a/Lib/test/_test_venv_multiprocessing.py
+++ b/Lib/test/_test_venv_multiprocessing.py
@@ -1,7 +1,6 @@
import multiprocessing
import random
import sys
-import time
def fill_queue(queue, code):
queue.put(code)
diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py
index c26c7aaaeb43..8c32895f5e09 100644
--- a/Lib/test/fork_wait.py
+++ b/Lib/test/fork_wait.py
@@ -9,7 +9,7 @@
active threads survive in the child after a fork(); this is an error.
"""
-import os, sys, time, unittest
+import os, time, unittest
import threading
from test import support
from test.support import threading_helper
diff --git a/Lib/test/test__xxinterpchannels.py b/Lib/test/test__xxinterpchannels.py
index 03bb5c80b8da..69bda89a1688 100644
--- a/Lib/test/test__xxinterpchannels.py
+++ b/Lib/test/test__xxinterpchannels.py
@@ -1,6 +1,5 @@
from collections import namedtuple
import contextlib
-import os
import sys
from textwrap import dedent
import threading
diff --git a/Lib/test/test__xxsubinterpreters.py b/Lib/test/test__xxsubinterpreters.py
index 687fcf3b7705..965967e3f273 100644
--- a/Lib/test/test__xxsubinterpreters.py
+++ b/Lib/test/test__xxsubinterpreters.py
@@ -1,4 +1,3 @@
-from collections import namedtuple
import contextlib
import itertools
import os
@@ -6,7 +5,6 @@
import sys
from textwrap import dedent
import threading
-import time
import unittest
import _testcapi
diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py
index 0421efdbf9da..09e4010b0e53 100644
--- a/Lib/test/test_asyncgen.py
+++ b/Lib/test/test_asyncgen.py
@@ -2,7 +2,6 @@
import types
import unittest
import contextlib
-import warnings
from test.support.import_helper import import_module
from test.support import gc_collect, requires_working_socket
diff --git a/Lib/test/test_asyncio/test_ssl.py b/Lib/test/test_asyncio/test_ssl.py
index aaf3c37101f5..e9cc735613fb 100644
--- a/Lib/test/test_asyncio/test_ssl.py
+++ b/Lib/test/test_asyncio/test_ssl.py
@@ -1,5 +1,4 @@
import asyncio
-import asyncio.sslproto
import contextlib
import gc
import logging
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index f1ad10a9903f..eba6e2d1f28f 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -1,5 +1,4 @@
import os
-import shutil
import signal
import sys
import unittest
diff --git a/Lib/test/test_ctypes/test_callbacks.py b/Lib/test/test_ctypes/test_callbacks.py
index e8fa3e6f7aca..b185e388ab15 100644
--- a/Lib/test/test_ctypes/test_callbacks.py
+++ b/Lib/test/test_ctypes/test_callbacks.py
@@ -1,4 +1,3 @@
-import sys
import functools
import unittest
from test import support
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index 81a36aa241ac..589f229f4623 100644
--- a/Lib/test/test_dataclasses.py
+++ b/Lib/test/test_dataclasses.py
@@ -2261,7 +2261,6 @@ def test_base_has_init(self):
class B:
def __init__(self):
self.z = 100
- pass
# Make sure that declaring this class doesn't raise an error.
# The issue is that we can't override __init__ in our class,
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 0a2e0c14d268..2b14590b2c21 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -20,7 +20,6 @@
from test import support
from test.support import ALWAYS_EQ
from test.support import threading_helper
-from textwrap import dedent
from datetime import timedelta
python_version = sys.version_info[:2]
@@ -1187,7 +1186,6 @@ class MyEnum(HexInt, enum.Enum):
#
class SillyInt(HexInt):
__qualname__ = 'SillyInt'
- pass
class MyOtherEnum(SillyInt, enum.Enum):
__qualname__ = 'MyOtherEnum'
D = 4
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 5b946020994e..ced9000f75f2 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -3,7 +3,6 @@
from test.support import check_syntax_error
from test.support import import_helper
-from test.support.warnings_helper import check_syntax_warning
import inspect
import unittest
import sys
@@ -15,7 +14,6 @@
# with import machinery
import test.ann_module as ann_module
import typing
-from collections import ChainMap
from test import ann_module2
import test
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 5ead88579435..08cb5eb0c2bb 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -22,7 +22,6 @@
from test.support import os_helper
from test.support import requires_resource
from test.support import threading_helper
-from test.support import warnings_helper
from http.client import HTTPException
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 620a5b19109a..9ff6afcbadec 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -8,7 +8,6 @@
import re
import socket
import threading
-import warnings
import unittest
from unittest import mock
@@ -17,7 +16,6 @@
from test import support
from test.support import os_helper
from test.support import socket_helper
-from test.support import warnings_helper
support.requires_working_socket(module=True)
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 7626d9572e1e..60f5b671b1da 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -13,7 +13,6 @@
from test.support import verbose, run_with_tz, run_with_locale, cpython_only
from test.support import hashlib_helper
from test.support import threading_helper
-from test.support import warnings_helper
import unittest
from unittest import mock
from datetime import datetime, timezone, timedelta
@@ -751,7 +750,6 @@ class NonUTF8Server(SimpleIMAPHandler):
typ, data = client.login('user', 'pass')
self.assertEqual(typ, 'OK')
client.enable('UTF8=ACCEPT')
- pass
@threading_helper.reap_threads
def test_enable_UTF8_True_append(self):
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index 2fcf6ebbee7e..bf9332e40aea 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -3,7 +3,6 @@
# testing of error conditions uncovered when using extension types.
import unittest
-import sys
import typing
from test import support
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index 2ca3908bd1ca..699265ccadc7 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -6,7 +6,6 @@
from test import support
import unittest
-import pyexpat
import xml.dom.minidom
from xml.dom.minidom import parse, Attr, Node, Document, parseString
diff --git a/Lib/test/test_peg_generator/test_c_parser.py b/Lib/test/test_peg_generator/test_c_parser.py
index 1b3fcbb92f82..d34ffef0dbc5 100644
--- a/Lib/test/test_peg_generator/test_c_parser.py
+++ b/Lib/test/test_peg_generator/test_c_parser.py
@@ -24,7 +24,6 @@
generate_parser_c_extension,
generate_c_parser_source,
)
- from pegen.ast_dump import ast_dump
TEST_TEMPLATE = """
diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py
index 92598dbbd5f2..797c91ee7eff 100644
--- a/Lib/test/test_shlex.py
+++ b/Lib/test/test_shlex.py
@@ -3,7 +3,6 @@
import shlex
import string
import unittest
-from unittest import mock
# The original test data set was from shellwords, by Hartmut Goebel.
diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py
index acae433cd0a5..49e076c77d16 100644
--- a/Lib/test/test_sys_setprofile.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -2,7 +2,6 @@
import pprint
import sys
import unittest
-from test import support
class TestGetProfile(unittest.TestCase):
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index a251b2272e95..4907c930e143 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -2,7 +2,6 @@
from test import support
import unittest
-from unittest.mock import MagicMock
import sys
import difflib
import gc
diff --git a/Lib/test/test_tkinter/test_widgets.py b/Lib/test/test_tkinter/test_widgets.py
index 6fde93cbecc7..64c947270654 100644
--- a/Lib/test/test_tkinter/test_widgets.py
+++ b/Lib/test/test_tkinter/test_widgets.py
@@ -9,8 +9,7 @@
AbstractDefaultRootTest)
from test.test_tkinter.widget_tests import (
add_standard_options,
- AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
- setUpModule)
+ AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
requires('gui')
diff --git a/Lib/test/test_tools/test_sundry.py b/Lib/test/test_tools/test_sundry.py
index 81f06763980a..6a3dc12781b2 100644
--- a/Lib/test/test_tools/test_sundry.py
+++ b/Lib/test/test_tools/test_sundry.py
@@ -6,7 +6,6 @@
"""
import os
-import sys
import unittest
from test.support import import_helper
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 95b1bae4f608..92c5a0005858 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -6,7 +6,6 @@
import sys
import types
import inspect
-import importlib
import builtins
import unittest
import re
diff --git a/Lib/test/test_ttk/test_widgets.py b/Lib/test/test_ttk/test_widgets.py
index 6f47ccb8e8b3..79d65b496abd 100644
--- a/Lib/test/test_ttk/test_widgets.py
+++ b/Lib/test/test_ttk/test_widgets.py
@@ -8,8 +8,7 @@
from test.test_tkinter.support import (AbstractTkTest, tcl_version, get_tk_patchlevel,
simulate_mouse_click, AbstractDefaultRootTest)
from test.test_tkinter.widget_tests import (add_standard_options,
- AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests,
- setUpModule)
+ AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
requires('gui')
@@ -50,7 +49,6 @@ def test_configure_style(self):
widget2 = self.create(class_='Foo')
self.assertEqual(widget2['class'], 'Foo')
# XXX
- pass
class WidgetTest(AbstractTkTest, unittest.TestCase):
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index 74503c89e559..3dc0790ca15b 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -12,8 +12,7 @@
import unicodedata
import unittest
from test.support import (open_urlresource, requires_resource, script_helper,
- cpython_only, check_disallow_instantiation,
- ResourceDenied)
+ cpython_only, check_disallow_instantiation)
class UnicodeMethodsTest(unittest.TestCase):
diff --git a/Lib/test/test_unittest/test_loader.py b/Lib/test/test_unittest/test_loader.py
index bbdfb247ebaa..a203145a791b 100644
--- a/Lib/test/test_unittest/test_loader.py
+++ b/Lib/test/test_unittest/test_loader.py
@@ -1,7 +1,6 @@
import functools
import sys
import types
-import warnings
import unittest
diff --git a/Lib/test/test_wmi.py b/Lib/test/test_wmi.py
index 3f5795952905..3445702846d8 100644
--- a/Lib/test/test_wmi.py
+++ b/Lib/test/test_wmi.py
@@ -1,7 +1,6 @@
# Test the internal _wmi module on Windows
# This is used by the platform module, and potentially others
-import sys
import unittest
from test.support import import_helper, requires_resource
diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py
index be654a8478b0..2e1affe02528 100644
--- a/Lib/test/test_zipfile64.py
+++ b/Lib/test/test_zipfile64.py
@@ -11,7 +11,7 @@
'test requires loads of disk-space bytes and a long time to run'
)
-import zipfile, os, unittest
+import zipfile, unittest
import time
import sys
More information about the Python-checkins
mailing list