Skip to content

bpo-29919: Remove unused imports found by pyflakes #137

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 27, 2017
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
7 changes: 6 additions & 1 deletion Lib/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
# find this format documented anywhere.


import locale, copy, io, os, re, struct, sys
import copy
import locale
import os
import re
import struct
import sys
from errno import ENOENT


Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import os
import sys

from tkinter.font import Font, nametofont
from tkinter.font import Font

class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
Expand Down
1 change: 0 additions & 1 deletion Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from idlelib import query
from idlelib import replace
from idlelib import search
from idlelib import textview
from idlelib import windows

# The default tab setting for a Text widget, in average-width characters.
Expand Down
2 changes: 0 additions & 2 deletions Lib/idlelib/idle_test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
Much is tested by opening config dialog live or in test_configdialog.
Coverage: 27%
'''
from sys import modules
from test.support import captured_stderr
from tkinter import Tk
import unittest
from idlelib import config

Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_config_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from test.support import requires
requires('gui')
import unittest
from tkinter import Tk, Text
from tkinter import Tk


class GetKeysTest(unittest.TestCase):
Expand Down
2 changes: 0 additions & 2 deletions Lib/idlelib/idle_test/test_editor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import unittest
from tkinter import Tk, Text
from idlelib.editor import EditorWindow
from test.support import requires

class Editor_func_test(unittest.TestCase):
def test_filename_to_unicode(self):
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_searchbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'''
import unittest
from test.support import requires
from tkinter import Tk, Toplevel, Frame ##, BooleanVar, StringVar
from tkinter import Tk, Frame ##, BooleanVar, StringVar
Copy link
Member

Choose a reason for hiding this comment

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

Why BooleanVar and StringVar are commented out?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are used in commented code a few lines below. I don't want to remove this commented code, since I don't know this file.

from idlelib import searchengine as se
from idlelib import searchbase as sdb
from idlelib.idle_test.mock_idle import Func
Expand Down
1 change: 0 additions & 1 deletion Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from code import InteractiveInterpreter
import getopt
import io
import linecache
import os
import os.path
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import os
from sys import executable, platform # Platform is set for one test.

from tkinter import Toplevel, StringVar, W, E, N, S
from tkinter import Toplevel, StringVar, W, E, S
from tkinter.ttk import Frame, Button, Entry, Label
from tkinter import filedialog
from tkinter.font import Font
Expand Down
2 changes: 1 addition & 1 deletion Lib/lib2to3/pgen2/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pickle

# Local imports
from . import token, tokenize
from . import token


class Grammar(object):
Expand Down
2 changes: 1 addition & 1 deletion Lib/multiprocessing/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Licensed to PSF under a Contributor Agreement.
#

from abc import ABCMeta, abstractmethod
from abc import ABCMeta
import copyreg
import functools
import io
Expand Down
1 change: 0 additions & 1 deletion Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re
import sys
from collections import Sequence
from contextlib import contextmanager
from errno import EINVAL, ENOENT, ENOTDIR
from operator import attrgetter
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
Expand Down
3 changes: 1 addition & 2 deletions Lib/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@
]

import collections
import decimal
import math
import numbers

from fractions import Fraction
from decimal import Decimal
from itertools import groupby, chain
from itertools import groupby
from bisect import bisect_left, bisect_right


Expand Down
1 change: 0 additions & 1 deletion Lib/test/ssl_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import sys
import ssl
import pprint
import socket
import urllib.parse
# Rename HTTPServer to _HTTPServer so as to avoid confusion with HTTPSServer.
from http.server import (HTTPServer as _HTTPServer,
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""Unit tests for abc.py."""

import unittest
from test import support

import abc
from inspect import isabstract
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import types
import unittest

from unittest import mock

from test.support import import_module
asyncio = import_module("asyncio")

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_asyncio/test_pep492.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tests support for new syntax introduced by PEP 492."""

import collections.abc
import types
import unittest

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_binop.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for binary operators on subtypes of built-in types."""

import unittest
from test import support
from operator import eq, le, ne
from abc import ABCMeta

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import unittest
import warnings
from operator import neg
from test.support import TESTFN, unlink, run_unittest, check_warnings
from test.support import TESTFN, unlink, check_warnings
from test.support.script_helper import assert_python_ok
try:
import pty, signal
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import collections
import copy
import doctest
import inspect
import keyword
import operator
import pickle
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import locale
from test.support import (run_unittest, run_doctest, is_resource_enabled,
requires_IEEE_754, requires_docstrings)
from test.support import (check_warnings, import_fresh_module, TestFailed,
from test.support import (import_fresh_module, TestFailed,
run_with_locale, cpython_only)
import random
import inspect
Expand Down Expand Up @@ -1170,7 +1170,6 @@ def get_fmt(x, override=None, fmt='n'):
@run_with_locale('LC_ALL', 'ps_AF')
def test_wide_char_separator_decimal_point(self):
# locale with wide char separator and decimal point
import locale
Decimal = self.decimal.Decimal

decimal_point = locale.localeconv()['decimal_point']
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_deque.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import weakref
import copy
import pickle
from io import StringIO
import random
import struct

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

from test import support

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_http_cookies.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Simple test suite for http/cookies.py

import copy
from test.support import run_unittest, run_doctest, check_warnings
from test.support import run_unittest, run_doctest
import unittest
from http import cookies
import pickle
import warnings


class CookieTests(unittest.TestCase):

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_imaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import socketserver
import time
import calendar
import inspect

from test.support import (reap_threads, verbose, transient_internet,
run_with_tz, run_with_locale)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_json/test_decode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import decimal
from io import StringIO, BytesIO
from io import StringIO
from collections import OrderedDict
from test.test_json import PyTest, CTest

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import sys
import builtins
import contextlib
import importlib.util
import inspect
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_re.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G, \
cpython_only, captured_stdout
from test.support import (gc_collect, bigmemtest, _2G,
cpython_only, captured_stdout)
import locale
import re
import sre_compile
Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import errno
import functools
import subprocess
from contextlib import ExitStack
from shutil import (make_archive,
register_archive_format, unregister_archive_format,
get_archive_formats, Error, unpack_archive,
Expand All @@ -22,8 +21,7 @@
import zipfile

from test import support
from test.support import (TESTFN, check_warnings, captured_stdout,
android_not_root)
from test.support import TESTFN, android_not_root

TESTFN2 = TESTFN + "2"

Expand Down
11 changes: 5 additions & 6 deletions Lib/test/test_signal.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import unittest
from test import support
from contextlib import closing
import select
import os
import signal
import socket
import struct
import subprocess
import sys, os, time, errno
import sys
import time
import unittest
from test import support
from test.support.script_helper import assert_python_ok, spawn_python
try:
import threading
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import codecs
import gc
import sysconfig
import platform
import locale

# count the number of test runs, used to create unique
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import itertools
import operator
import struct
import string
import sys
import unittest
import warnings
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from test.support import script_helper
from test.support import (TESTFN, findfile, unlink, rmtree, temp_dir, temp_cwd,
requires_zlib, requires_bz2, requires_lzma,
captured_stdout, check_warnings)
captured_stdout)

TESTFN2 = TESTFN + "2"
TESTFNDIR = TESTFN + "d"
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_zipfile64.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import time
import sys

from io import StringIO
from tempfile import TemporaryFile

from test.support import TESTFN, requires_zlib
Expand Down
2 changes: 1 addition & 1 deletion Lib/unittest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

__unittest = True

from .main import main, TestProgram
from .main import main
Copy link
Member

Choose a reason for hiding this comment

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

This looks suspicious. Are you sure that TestProgram is not needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Lib/unittest/main.py ends with "main = TestProgram". And TestProgram is not used in Lib/unittest/main.py.


main(module=None)
1 change: 0 additions & 1 deletion Modules/_decimal/tests/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


import time
from math import log, ceil
try:
from test.support import import_fresh_module
except ImportError:
Expand Down
1 change: 0 additions & 1 deletion PCbuild/prepare_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from __future__ import print_function

import os
import re
import sys
import subprocess
from shutil import copy
Expand Down
2 changes: 0 additions & 2 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import abc
import ast
import atexit
import collections
import contextlib
import copy
Expand All @@ -27,7 +26,6 @@
import textwrap
import traceback
import types
import uuid

from types import *
NoneType = type(None)
Expand Down
2 changes: 1 addition & 1 deletion Tools/msi/make_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from itertools import chain
from pathlib import Path
from zipfile import ZipFile, ZIP_DEFLATED
import subprocess


TKTCL_RE = re.compile(r'^(_?tk|tcl).+\.(pyd|dll)', re.IGNORECASE)
DEBUG_RE = re.compile(r'_d\.(pyd|dll|exe|pdb|lib)$', re.IGNORECASE)
Expand Down
2 changes: 1 addition & 1 deletion Tools/tz/zdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import struct
from array import array
from collections import namedtuple
from datetime import datetime, timedelta
from datetime import datetime

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

Expand Down