Skip to content

gh-131152: Remove unused imports from tests (part 2) #131154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/test_free_threading/test_func_annotations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import concurrent.futures
import unittest
import inspect
from threading import Thread, Barrier
from threading import Barrier
from unittest import TestCase

from test.support import threading_helper, Py_GIL_DISABLED
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_free_threading/test_itertools_batched.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import sys
from threading import Thread, Barrier
from itertools import batched
from test.support import threading_helper
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_free_threading/test_methodcaller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
from threading import Thread
from test.support import threading_helper
from operator import methodcaller


Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import unittest
import warnings

from test import support
from test.support import is_wasi, Py_DEBUG
from test.support.os_helper import (TESTFN, skip_unless_symlink,
can_symlink, create_empty_file, change_cwd)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from importlib import _bootstrap_external
from test.support import os_helper
import unittest
import sys
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_importlib/resources/test_files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os
import pathlib
import py_compile
import shutil
import textwrap
import unittest
import warnings
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_importlib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from importlib import _bootstrap_external
import os
import pathlib
import re
import string
import sys
from test import support
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ def test_defaults_UTF8(self):
# valid. Furthermore LC_CTYPE=UTF is used by the UTF-8 locale coercing
# during interpreter startup (on macOS).
import _locale
import os

self.assertEqual(locale._parse_localename('UTF-8'), (None, 'UTF-8'))

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from test.support import import_helper
from test.support import is_emscripten, is_wasi
from test.support import infinite_recursion
from test.support import swap_attr
from test.support import os_helper
from test.support.os_helper import TESTFN, FakePath
from test.test_pathlib import test_pathlib_abc
Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_pathlib/test_pathlib_abc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import collections
import io
import os
import errno
import unittest

from pathlib._os import magic_open
from pathlib.types import _PathParser, PathInfo, _JoinablePath, _ReadablePath, _WritablePath
from pathlib.types import _JoinablePath, _ReadablePath, _WritablePath
import posixpath

from test.support.os_helper import TESTFN
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_pkgutil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path
from test.support.import_helper import unload, CleanImport
from test.support.warnings_helper import check_warnings, ignore_warnings
from test.support.import_helper import unload
from test.support.warnings_helper import check_warnings
import unittest
import sys
import importlib
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pyrepl/support.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from code import InteractiveConsole
from functools import partial
from typing import Iterable
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pyrepl/test_eventqueue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import tempfile
import unittest
import sys
from unittest.mock import patch
from test import support

Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import os.path
import errno
import functools
import pathlib
import subprocess
import random
import string
Expand All @@ -32,7 +31,6 @@
from test import support
from test.support import os_helper
from test.support.os_helper import TESTFN, FakePath
from test.support import warnings_helper

TESTFN2 = TESTFN + "2"
TESTFN_SRC = TESTFN + "_SRC"
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from test import support
from test.support import os_helper
from test.support import script_helper
from test.support import warnings_helper

# Check for our compression modules.
try:
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_thread_local_bytecode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for thread-local bytecode."""
import dis
import textwrap
import unittest

Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Python test set -- part 6, built-in types

from test.support import (
run_with_locale, is_apple_mobile, cpython_only, no_rerun,
iter_builtin_types, iter_slot_wrappers,
run_with_locale, cpython_only, no_rerun,
MISSING_C_DOCSTRINGS,
)
import collections.abc
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_userdict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Check every path through every method of UserDict

from test import mapping_tests, support
from test import mapping_tests
import unittest
import collections

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_userlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections import UserList
from test import list_tests
import unittest
from test import support


class UserListTest(list_tests.CommonTest):
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_wmi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Test the internal _wmi module on Windows
# This is used by the platform module, and potentially others

import time
import unittest
from test import support
from test.support import import_helper
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_zipfile/_path/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pickle
import stat
import sys
import time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will get overwritten unless it's ported to zipp. I'm slightly surprised that there are unused imports, given that I run ruff over the codebase. Oh, I see now. gh-123424 has not yet been backported to zipp, and that's where time was used. So shouldn't be a problem getting this synced once that one is.

import unittest
import zipfile
import zipfile._path
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_zipfile/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from test.support import (
findfile, requires_zlib, requires_bz2, requires_lzma,
captured_stdout, captured_stderr, requires_subprocess,
is_emscripten
)
from test.support.os_helper import (
TESTFN, unlink, rmtree, temp_dir, temp_cwd, fd_count, FakePath
Expand Down
Loading