Skip to content

Commit d6debb2

Browse files
authored
bpo-29919: Remove unused imports found by pyflakes (python#137)
Make also minor PEP8 coding style fixes on modified imports.
1 parent 604e74c commit d6debb2

40 files changed

+30
-55
lines changed

Lib/gettext.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@
4646
# find this format documented anywhere.
4747

4848

49-
import locale, copy, io, os, re, struct, sys
49+
import copy
50+
import locale
51+
import os
52+
import re
53+
import struct
54+
import sys
5055
from errno import ENOENT
5156

5257

Lib/idlelib/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import os
3030
import sys
3131

32-
from tkinter.font import Font, nametofont
32+
from tkinter.font import Font
3333

3434
class InvalidConfigType(Exception): pass
3535
class InvalidConfigSet(Exception): pass

Lib/idlelib/editor.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from idlelib import query
2727
from idlelib import replace
2828
from idlelib import search
29-
from idlelib import textview
3029
from idlelib import windows
3130

3231
# The default tab setting for a Text widget, in average-width characters.

Lib/idlelib/idle_test/test_config.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
Much is tested by opening config dialog live or in test_configdialog.
44
Coverage: 27%
55
'''
6-
from sys import modules
76
from test.support import captured_stderr
8-
from tkinter import Tk
97
import unittest
108
from idlelib import config
119

Lib/idlelib/idle_test/test_config_key.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from test.support import requires
77
requires('gui')
88
import unittest
9-
from tkinter import Tk, Text
9+
from tkinter import Tk
1010

1111

1212
class GetKeysTest(unittest.TestCase):

Lib/idlelib/idle_test/test_editor.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import unittest
2-
from tkinter import Tk, Text
32
from idlelib.editor import EditorWindow
4-
from test.support import requires
53

64
class Editor_func_test(unittest.TestCase):
75
def test_filename_to_unicode(self):

Lib/idlelib/idle_test/test_searchbase.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'''
66
import unittest
77
from test.support import requires
8-
from tkinter import Tk, Toplevel, Frame ##, BooleanVar, StringVar
8+
from tkinter import Tk, Frame ##, BooleanVar, StringVar
99
from idlelib import searchengine as se
1010
from idlelib import searchbase as sdb
1111
from idlelib.idle_test.mock_idle import Func

Lib/idlelib/pyshell.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from code import InteractiveInterpreter
2121
import getopt
22-
import io
2322
import linecache
2423
import os
2524
import os.path

Lib/idlelib/query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import os
2525
from sys import executable, platform # Platform is set for one test.
2626

27-
from tkinter import Toplevel, StringVar, W, E, N, S
27+
from tkinter import Toplevel, StringVar, W, E, S
2828
from tkinter.ttk import Frame, Button, Entry, Label
2929
from tkinter import filedialog
3030
from tkinter.font import Font

Lib/lib2to3/pgen2/grammar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import pickle
1818

1919
# Local imports
20-
from . import token, tokenize
20+
from . import token
2121

2222

2323
class Grammar(object):

Lib/multiprocessing/reduction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Licensed to PSF under a Contributor Agreement.
88
#
99

10-
from abc import ABCMeta, abstractmethod
10+
from abc import ABCMeta
1111
import copyreg
1212
import functools
1313
import io

Lib/pathlib.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import re
88
import sys
99
from collections import Sequence
10-
from contextlib import contextmanager
1110
from errno import EINVAL, ENOENT, ENOTDIR
1211
from operator import attrgetter
1312
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO

Lib/statistics.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@
8383
]
8484

8585
import collections
86-
import decimal
8786
import math
8887
import numbers
8988

9089
from fractions import Fraction
9190
from decimal import Decimal
92-
from itertools import groupby, chain
91+
from itertools import groupby
9392
from bisect import bisect_left, bisect_right
9493

9594

Lib/test/ssl_servers.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sys
33
import ssl
44
import pprint
5-
import socket
65
import urllib.parse
76
# Rename HTTPServer to _HTTPServer so as to avoid confusion with HTTPSServer.
87
from http.server import (HTTPServer as _HTTPServer,

Lib/test/test_abc.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""Unit tests for abc.py."""
55

66
import unittest
7-
from test import support
87

98
import abc
109
from inspect import isabstract

Lib/test/test_asyncgen.py

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import types
33
import unittest
44

5-
from unittest import mock
6-
75
from test.support import import_module
86
asyncio = import_module("asyncio")
97

Lib/test/test_asyncio/test_pep492.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests support for new syntax introduced by PEP 492."""
22

3-
import collections.abc
43
import types
54
import unittest
65

Lib/test/test_binop.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Tests for binary operators on subtypes of built-in types."""
22

33
import unittest
4-
from test import support
54
from operator import eq, le, ne
65
from abc import ABCMeta
76

Lib/test/test_builtin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import unittest
1919
import warnings
2020
from operator import neg
21-
from test.support import TESTFN, unlink, run_unittest, check_warnings
21+
from test.support import TESTFN, unlink, check_warnings
2222
from test.support.script_helper import assert_python_ok
2323
try:
2424
import pty, signal

Lib/test/test_collections.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import collections
44
import copy
55
import doctest
6-
import inspect
76
import keyword
87
import operator
98
import pickle

Lib/test/test_decimal.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import locale
3535
from test.support import (run_unittest, run_doctest, is_resource_enabled,
3636
requires_IEEE_754, requires_docstrings)
37-
from test.support import (check_warnings, import_fresh_module, TestFailed,
37+
from test.support import (import_fresh_module, TestFailed,
3838
run_with_locale, cpython_only)
3939
import random
4040
import inspect
@@ -1170,7 +1170,6 @@ def get_fmt(x, override=None, fmt='n'):
11701170
@run_with_locale('LC_ALL', 'ps_AF')
11711171
def test_wide_char_separator_decimal_point(self):
11721172
# locale with wide char separator and decimal point
1173-
import locale
11741173
Decimal = self.decimal.Decimal
11751174

11761175
decimal_point = locale.localeconv()['decimal_point']

Lib/test/test_deque.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import weakref
66
import copy
77
import pickle
8-
from io import StringIO
98
import random
109
import struct
1110

Lib/test/test_generators.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import warnings
77
import weakref
88
import inspect
9-
import types
109

1110
from test import support
1211

Lib/test/test_http_cookies.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Simple test suite for http/cookies.py
22

33
import copy
4-
from test.support import run_unittest, run_doctest, check_warnings
4+
from test.support import run_unittest, run_doctest
55
import unittest
66
from http import cookies
77
import pickle
8-
import warnings
8+
99

1010
class CookieTests(unittest.TestCase):
1111

Lib/test/test_imaplib.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import socketserver
1111
import time
1212
import calendar
13-
import inspect
1413

1514
from test.support import (reap_threads, verbose, transient_internet,
1615
run_with_tz, run_with_locale)

Lib/test/test_json/test_decode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import decimal
2-
from io import StringIO, BytesIO
2+
from io import StringIO
33
from collections import OrderedDict
44
from test.test_json import PyTest, CTest
55

Lib/test/test_pydoc.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import sys
3-
import builtins
43
import contextlib
54
import importlib.util
65
import inspect

Lib/test/test_re.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G, \
2-
cpython_only, captured_stdout
1+
from test.support import (gc_collect, bigmemtest, _2G,
2+
cpython_only, captured_stdout)
33
import locale
44
import re
55
import sre_compile

Lib/test/test_shutil.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import errno
1212
import functools
1313
import subprocess
14-
from contextlib import ExitStack
1514
from shutil import (make_archive,
1615
register_archive_format, unregister_archive_format,
1716
get_archive_formats, Error, unpack_archive,
@@ -22,8 +21,7 @@
2221
import zipfile
2322

2423
from test import support
25-
from test.support import (TESTFN, check_warnings, captured_stdout,
26-
android_not_root)
24+
from test.support import TESTFN, android_not_root
2725

2826
TESTFN2 = TESTFN + "2"
2927

Lib/test/test_signal.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import unittest
2-
from test import support
3-
from contextlib import closing
4-
import select
1+
import os
52
import signal
63
import socket
7-
import struct
84
import subprocess
9-
import sys, os, time, errno
5+
import sys
6+
import time
7+
import unittest
8+
from test import support
109
from test.support.script_helper import assert_python_ok, spawn_python
1110
try:
1211
import threading

Lib/test/test_sys.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import codecs
1010
import gc
1111
import sysconfig
12-
import platform
1312
import locale
1413

1514
# count the number of test runs, used to create unique

Lib/test/test_unicode.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import itertools
1111
import operator
1212
import struct
13-
import string
1413
import sys
1514
import unittest
1615
import warnings

Lib/test/test_zipfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from test.support import script_helper
1717
from test.support import (TESTFN, findfile, unlink, rmtree, temp_dir, temp_cwd,
1818
requires_zlib, requires_bz2, requires_lzma,
19-
captured_stdout, check_warnings)
19+
captured_stdout)
2020

2121
TESTFN2 = TESTFN + "2"
2222
TESTFNDIR = TESTFN + "d"

Lib/test/test_zipfile64.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import time
1616
import sys
1717

18-
from io import StringIO
1918
from tempfile import TemporaryFile
2019

2120
from test.support import TESTFN, requires_zlib

Lib/unittest/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
__unittest = True
1515

16-
from .main import main, TestProgram
16+
from .main import main
1717

1818
main(module=None)

Modules/_decimal/tests/bench.py

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

88

99
import time
10-
from math import log, ceil
1110
try:
1211
from test.support import import_fresh_module
1312
except ImportError:

PCbuild/prepare_ssl.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from __future__ import print_function
2222

2323
import os
24-
import re
2524
import sys
2625
import subprocess
2726
from shutil import copy

Tools/clinic/clinic.py

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

88
import abc
99
import ast
10-
import atexit
1110
import collections
1211
import contextlib
1312
import copy
@@ -27,7 +26,6 @@
2726
import textwrap
2827
import traceback
2928
import types
30-
import uuid
3129

3230
from types import *
3331
NoneType = type(None)

Tools/msi/make_zip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from itertools import chain
1111
from pathlib import Path
1212
from zipfile import ZipFile, ZIP_DEFLATED
13-
import subprocess
13+
1414

1515
TKTCL_RE = re.compile(r'^(_?tk|tcl).+\.(pyd|dll)', re.IGNORECASE)
1616
DEBUG_RE = re.compile(r'_d\.(pyd|dll|exe|pdb|lib)$', re.IGNORECASE)

Tools/tz/zdump.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import struct
44
from array import array
55
from collections import namedtuple
6-
from datetime import datetime, timedelta
6+
from datetime import datetime
77

88
ttinfo = namedtuple('ttinfo', ['tt_gmtoff', 'tt_isdst', 'tt_abbrind'])
99

0 commit comments

Comments
 (0)