From e62f238b0dad091175f47df25a0ae41042a54382 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sat, 23 Sep 2023 16:08:02 +0100 Subject: [PATCH 1/3] Remove unused imports in the `Lib/` directory --- Lib/asyncio/tasks.py | 1 - Lib/test/mapping_tests.py | 1 - Lib/test/support/interpreters.py | 2 +- Lib/test/test_asyncio/test_eager_task_factory.py | 1 - Lib/test/test_capi/test_abstract.py | 3 --- Lib/test/test_capi/test_dict.py | 3 --- Lib/test/test_capi/test_misc.py | 2 +- Lib/test/test_csv.py | 2 +- Lib/test/test_decimal.py | 1 - Lib/test/test_dictviews.py | 1 - Lib/test/test_importlib/import_/test_packages.py | 1 - Lib/test/test_peg_generator/__init__.py | 1 - Lib/test/test_pyexpat.py | 3 +-- Lib/test/test_sqlite3/test_dump.py | 1 - Lib/test/test_sqlite3/test_userfunctions.py | 2 +- Lib/test/test_sqlite3/util.py | 1 - Lib/test/test_tkinter/support.py | 1 - Lib/test/test_unittest/testmock/testthreadingmock.py | 2 +- Lib/test/test_zlib.py | 1 - 19 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index edc64fda2a6ad6..21a1b24194bcd8 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -17,7 +17,6 @@ import itertools import math import types -import warnings import weakref from types import GenericAlias diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py index b3e4192e65d957..b4cfce19a7174e 100644 --- a/Lib/test/mapping_tests.py +++ b/Lib/test/mapping_tests.py @@ -1,7 +1,6 @@ # tests common to dict and UserDict import unittest import collections -import sys from test.support import Py_C_RECURSION_LIMIT diff --git a/Lib/test/support/interpreters.py b/Lib/test/support/interpreters.py index 5c484d1170d1d9..eeff3abe0324e5 100644 --- a/Lib/test/support/interpreters.py +++ b/Lib/test/support/interpreters.py @@ -5,7 +5,7 @@ import _xxinterpchannels as _channels # aliases: -from _xxsubinterpreters import is_shareable, RunFailedError +from _xxsubinterpreters import is_shareable from _xxinterpchannels import ( ChannelError, ChannelNotFoundError, ChannelEmptyError, ) diff --git a/Lib/test/test_asyncio/test_eager_task_factory.py b/Lib/test/test_asyncio/test_eager_task_factory.py index fc9ad8eb43bb1b..0f8212dbec47be 100644 --- a/Lib/test/test_asyncio/test_eager_task_factory.py +++ b/Lib/test/test_asyncio/test_eager_task_factory.py @@ -7,7 +7,6 @@ from unittest import mock from asyncio import tasks from test.test_asyncio import utils as test_utils -import test.support from test.support.script_helper import assert_python_ok MOCK_ANY = mock.ANY diff --git a/Lib/test/test_capi/test_abstract.py b/Lib/test/test_capi/test_abstract.py index 7fad853ff54fe3..eeaef60a8b47b5 100644 --- a/Lib/test/test_capi/test_abstract.py +++ b/Lib/test/test_capi/test_abstract.py @@ -1,8 +1,5 @@ import unittest -import sys from collections import OrderedDict -from test import support -from test.support import import_helper import _testcapi diff --git a/Lib/test/test_capi/test_dict.py b/Lib/test/test_capi/test_dict.py index b22fa20e14dfea..11b2ca910707df 100644 --- a/Lib/test/test_capi/test_dict.py +++ b/Lib/test/test_capi/test_dict.py @@ -1,9 +1,6 @@ import unittest -import sys from collections import OrderedDict, UserDict from types import MappingProxyType -from test import support -from test.support import import_helper import _testcapi diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index cf1cba3e693ef6..5ece213e7b2363 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -2,7 +2,7 @@ # these are all functions _testcapi exports whose name begins with 'test_'. import _thread -from collections import OrderedDict, deque +from collections import deque import contextlib import importlib.machinery import importlib.util diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index 27f4978ca66a88..97b9bba24bcbca 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -10,7 +10,7 @@ import gc import pickle from test import support -from test.support import warnings_helper, import_helper, check_disallow_instantiation +from test.support import import_helper, check_disallow_instantiation from itertools import permutations from textwrap import dedent from collections import OrderedDict diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index d806eeac25fb2f..bd299483e7b0bd 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -41,7 +41,6 @@ darwin_malloc_err_warning, is_emscripten) from test.support.import_helper import import_fresh_module from test.support import threading_helper -from test.support import warnings_helper import random import inspect import threading diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index 34918585513846..cad568b6ac4c2d 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -1,7 +1,6 @@ import collections.abc import copy import pickle -import sys import unittest from test.support import Py_C_RECURSION_LIMIT diff --git a/Lib/test/test_importlib/import_/test_packages.py b/Lib/test/test_importlib/import_/test_packages.py index eb0831f7d6d54b..0c29d6083265fa 100644 --- a/Lib/test/test_importlib/import_/test_packages.py +++ b/Lib/test/test_importlib/import_/test_packages.py @@ -1,7 +1,6 @@ from test.test_importlib import util import sys import unittest -from test import support from test.support import import_helper diff --git a/Lib/test/test_peg_generator/__init__.py b/Lib/test/test_peg_generator/__init__.py index c23542e254c99f..b32db4426f251d 100644 --- a/Lib/test/test_peg_generator/__init__.py +++ b/Lib/test/test_peg_generator/__init__.py @@ -1,5 +1,4 @@ import os.path -import unittest from test import support from test.support import load_package_tests diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 41f4d172f8d057..a542abaf1f35aa 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -2,7 +2,6 @@ # handler, are obscure and unhelpful. import os -import platform import sys import sysconfig import unittest @@ -14,7 +13,7 @@ from xml.parsers import expat from xml.parsers.expat import errors -from test.support import sortdict, is_emscripten, is_wasi +from test.support import sortdict class SetAttributeTest(unittest.TestCase): diff --git a/Lib/test/test_sqlite3/test_dump.py b/Lib/test/test_sqlite3/test_dump.py index 3107e1b165d950..14a18c1ad37102 100644 --- a/Lib/test/test_sqlite3/test_dump.py +++ b/Lib/test/test_sqlite3/test_dump.py @@ -1,7 +1,6 @@ # Author: Paul Kippes import unittest -import sqlite3 as sqlite from .util import memory_database from .util import MemoryDatabaseMixin diff --git a/Lib/test/test_sqlite3/test_userfunctions.py b/Lib/test/test_sqlite3/test_userfunctions.py index 09019498fd5682..c6c3db159add64 100644 --- a/Lib/test/test_sqlite3/test_userfunctions.py +++ b/Lib/test/test_sqlite3/test_userfunctions.py @@ -29,7 +29,7 @@ from test.support import bigmemtest, gc_collect from .util import cx_limit, memory_database -from .util import with_tracebacks, check_tracebacks +from .util import with_tracebacks def func_returntext(): diff --git a/Lib/test/test_sqlite3/util.py b/Lib/test/test_sqlite3/util.py index 505406c437b632..5599823838beea 100644 --- a/Lib/test/test_sqlite3/util.py +++ b/Lib/test/test_sqlite3/util.py @@ -4,7 +4,6 @@ import re import sqlite3 import test.support -import unittest # Helper for temporary memory databases diff --git a/Lib/test/test_tkinter/support.py b/Lib/test/test_tkinter/support.py index 10e64bf40a4afa..a37705f0ae6feb 100644 --- a/Lib/test/test_tkinter/support.py +++ b/Lib/test/test_tkinter/support.py @@ -1,6 +1,5 @@ import functools import tkinter -import unittest class AbstractTkTest: diff --git a/Lib/test/test_unittest/testmock/testthreadingmock.py b/Lib/test/test_unittest/testmock/testthreadingmock.py index 94e71921d9bc03..a02b532ed447cd 100644 --- a/Lib/test/test_unittest/testmock/testthreadingmock.py +++ b/Lib/test/test_unittest/testmock/testthreadingmock.py @@ -3,7 +3,7 @@ import concurrent.futures from test.support import threading_helper -from unittest.mock import patch, ThreadingMock, call +from unittest.mock import patch, ThreadingMock threading_helper.requires_working_threading(module=True) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 55306c63cd4e16..9a099adc74f4b4 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -3,7 +3,6 @@ from test.support import import_helper import binascii import copy -import os import pickle import random import sys From 82d73a08b73af78e9db4e3a046e8209608ba1515 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sat, 23 Sep 2023 16:29:32 +0100 Subject: [PATCH 2/3] two more --- Lib/test/test_gdb.py | 1 - Lib/test/test_monitoring.py | 1 - 2 files changed, 2 deletions(-) diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index 914ef942feab12..5a4394a0993c8d 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -4,7 +4,6 @@ # Lib/test/test_jit_gdb.py import os -import platform import re import subprocess import sys diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index 2100d998ff0808..5a5e4d47a12536 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -8,7 +8,6 @@ import textwrap import types import unittest -import asyncio PAIR = (0,1) From 61a1a35e222304bed04fa056417fc992f4253a1b Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 24 Sep 2023 13:30:28 +0100 Subject: [PATCH 3/3] revert changes to test_monitoring --- Lib/test/test_monitoring.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index 5a5e4d47a12536..2100d998ff0808 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -8,6 +8,7 @@ import textwrap import types import unittest +import asyncio PAIR = (0,1)