Issue #20976: pyflakes: Remove unused imports

This commit is contained in:
Victor Stinner 2014-03-20 09:16:38 +01:00
parent 69b1e261fc
commit 7fa767e517
43 changed files with 11 additions and 64 deletions

View File

@ -14,7 +14,7 @@ import time
import locale import locale
import calendar import calendar
from re import compile as re_compile from re import compile as re_compile
from re import IGNORECASE, ASCII from re import IGNORECASE
from re import escape as re_escape from re import escape as re_escape
from datetime import (date as datetime_date, from datetime import (date as datetime_date,
timedelta as datetime_timedelta, timedelta as datetime_timedelta,

View File

@ -45,7 +45,6 @@ command will be accumulated (using your own 'collect_incoming_data'
method) up to the terminator, and then control will be returned to method) up to the terminator, and then control will be returned to
you - by calling your self.found_terminator() method. you - by calling your self.found_terminator() method.
""" """
import socket
import asyncore import asyncore
from collections import deque from collections import deque

View File

@ -12,7 +12,6 @@ See module py_compile for details of the actual byte-compilation.
""" """
import os import os
import sys import sys
import errno
import importlib.util import importlib.util
import py_compile import py_compile
import struct import struct

View File

@ -85,7 +85,7 @@ if os.name == "posix" and sys.platform == "darwin":
elif os.name == "posix": elif os.name == "posix":
# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
import re, tempfile, errno import re, tempfile
def _findLib_gcc(name): def _findLib_gcc(name):
expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)

View File

@ -142,7 +142,6 @@ __version__ = '1.70' # Highest version of the spec this complies with
# See http://speleotrove.com/decimal/ # See http://speleotrove.com/decimal/
__libmpdec_version__ = "2.4.0" # compatible libmpdec version __libmpdec_version__ = "2.4.0" # compatible libmpdec version
import copy as _copy
import math as _math import math as _math
import numbers as _numbers import numbers as _numbers
import sys import sys

View File

@ -30,7 +30,6 @@ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff', 'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff',
'unified_diff', 'HtmlDiff', 'Match'] 'unified_diff', 'HtmlDiff', 'Match']
import warnings
import heapq import heapq
from collections import namedtuple as _namedtuple from collections import namedtuple as _namedtuple

View File

@ -70,7 +70,7 @@ XXX: provide complete list of token types.
import re import re
import urllib # For urllib.parse.unquote import urllib # For urllib.parse.unquote
from string import hexdigits from string import hexdigits
from collections import namedtuple, OrderedDict from collections import OrderedDict
from email import _encoded_words as _ew from email import _encoded_words as _ew
from email import errors from email import errors
from email import utils from email import utils

View File

@ -10,14 +10,10 @@ import re
import sys import sys
import time import time
import random import random
import warnings
from copy import deepcopy from copy import deepcopy
from io import StringIO, BytesIO from io import StringIO, BytesIO
from email._policybase import compat32
from email.header import Header
from email.utils import _has_surrogates from email.utils import _has_surrogates
import email.charset as _charset
UNDERSCORE = '_' UNDERSCORE = '_'
NL = '\n' # XXX: no longer used by the code below. NL = '\n' # XXX: no longer used by the code below.

View File

@ -100,7 +100,6 @@ def decode_header(header):
words.append((encoded, encoding, charset)) words.append((encoded, encoding, charset))
# Now loop over words and remove words that consist of whitespace # Now loop over words and remove words that consist of whitespace
# between two encoded strings. # between two encoded strings.
import sys
droplist = [] droplist = []
for n, w in enumerate(words): for n, w in enumerate(words):
if n>1 and w[1] and words[n-2][1] and words[n-1][0].isspace(): if n>1 and w[1] and words[n-2][1] and words[n-1][0].isspace():
@ -362,7 +361,6 @@ class Header:
for string, charset in self._chunks: for string, charset in self._chunks:
if hasspace is not None: if hasspace is not None:
hasspace = string and self._nonctext(string[0]) hasspace = string and self._nonctext(string[0])
import sys
if lastcs not in (None, 'us-ascii'): if lastcs not in (None, 'us-ascii'):
if not hasspace or charset not in (None, 'us-ascii'): if not hasspace or charset not in (None, 'us-ascii'):
formatter.add_transition() formatter.add_transition()

View File

@ -6,7 +6,6 @@
__all__ = ['MIMEText'] __all__ = ['MIMEText']
from email.encoders import encode_7or8bit
from email.mime.nonmultipart import MIMENonMultipart from email.mime.nonmultipart import MIMENonMultipart

View File

@ -7,11 +7,9 @@
__all__ = ['Parser', 'HeaderParser', 'BytesParser', 'BytesHeaderParser', __all__ = ['Parser', 'HeaderParser', 'BytesParser', 'BytesHeaderParser',
'FeedParser', 'BytesFeedParser'] 'FeedParser', 'BytesFeedParser']
import warnings
from io import StringIO, TextIOWrapper from io import StringIO, TextIOWrapper
from email.feedparser import FeedParser, BytesFeedParser from email.feedparser import FeedParser, BytesFeedParser
from email.message import Message
from email._policybase import compat32 from email._policybase import compat32

View File

@ -40,7 +40,6 @@ __all__ = [
] ]
import re import re
import io
from string import ascii_letters, digits, hexdigits from string import ascii_letters, digits, hexdigits

View File

@ -25,13 +25,10 @@ __all__ = [
import os import os
import re import re
import time import time
import base64
import random import random
import socket import socket
import datetime import datetime
import urllib.parse import urllib.parse
import warnings
from io import StringIO
from email._parseaddr import quote from email._parseaddr import quote
from email._parseaddr import AddressList as _AddressList from email._parseaddr import AddressList as _AddressList

View File

@ -19,7 +19,7 @@ except ImportError:
pass pass
from abc import get_cache_token from abc import get_cache_token
from collections import namedtuple from collections import namedtuple
from types import MappingProxyType, MethodType from types import MappingProxyType
from weakref import WeakKeyDictionary from weakref import WeakKeyDictionary
try: try:
from _thread import RLock from _thread import RLock

View File

@ -73,7 +73,6 @@ import os
import socket import socket
import collections import collections
from urllib.parse import urlsplit from urllib.parse import urlsplit
import warnings
__all__ = ["HTTPResponse", "HTTPConnection", __all__ = ["HTTPResponse", "HTTPConnection",
"HTTPException", "NotConnected", "UnknownProtocol", "HTTPException", "NotConnected", "UnknownProtocol",

View File

@ -85,8 +85,6 @@ __version__ = "0.6"
__all__ = ["HTTPServer", "BaseHTTPRequestHandler"] __all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
import html import html
import email.message
import email.parser
import http.client import http.client
import io import io
import mimetypes import mimetypes

View File

@ -24,7 +24,7 @@ Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away! To use, simply 'import logging' and log away!
""" """
import sys, logging, logging.handlers, socket, struct, traceback, re import sys, logging, logging.handlers, struct, traceback, re
import io import io
try: try:

View File

@ -23,8 +23,7 @@ Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away! To use, simply 'import logging.handlers' and log away!
""" """
import errno, logging, socket, os, pickle, struct, time, re import logging, socket, os, pickle, struct, time, re
from codecs import BOM_UTF8
from stat import ST_DEV, ST_INO, ST_MTIME from stat import ST_DEV, ST_INO, ST_MTIME
import queue import queue
try: try:

View File

@ -6,7 +6,6 @@
# or returning from a flush() method. See functions _sync_flush() and # or returning from a flush() method. See functions _sync_flush() and
# _sync_close(). # _sync_close().
import sys
import os import os
import time import time
import calendar import calendar

View File

@ -14,7 +14,6 @@ import os
import sys import sys
import socket import socket
import struct import struct
import errno
import time import time
import tempfile import tempfile
import itertools import itertools

View File

@ -8,13 +8,11 @@
# #
import bisect import bisect
import itertools
import mmap import mmap
import os import os
import sys import sys
import tempfile import tempfile
import threading import threading
import _multiprocessing
from . import context from . import context
from . import reduction from . import reduction

View File

@ -24,7 +24,7 @@ import traceback
# If threading is available then ThreadPool should be provided. Therefore # If threading is available then ThreadPool should be provided. Therefore
# we avoid top-level imports which are liable to fail on some systems. # we avoid top-level imports which are liable to fail on some systems.
from . import util from . import util
from . import get_context, cpu_count, TimeoutError from . import get_context, TimeoutError
# #
# Constants representing the state of a pool # Constants representing the state of a pool

View File

@ -1,4 +1,3 @@
import fcntl
import io import io
import os import os
@ -8,8 +7,6 @@ from . import reduction
from . import spawn from . import spawn
from . import util from . import util
from . import current_process
__all__ = ['Popen'] __all__ = ['Popen']

View File

@ -16,7 +16,6 @@ import socket
import sys import sys
from . import context from . import context
from . import util
__all__ = ['send_handle', 'recv_handle', 'ForkingPickler', 'register', 'dump'] __all__ = ['send_handle', 'recv_handle', 'ForkingPickler', 'register', 'dump']

View File

@ -11,7 +11,6 @@
# python" would probably leave unlinked semaphores. # python" would probably leave unlinked semaphores.
# #
import errno
import os import os
import signal import signal
import sys import sys
@ -21,7 +20,6 @@ import _multiprocessing
from . import spawn from . import spawn
from . import util from . import util
from . import current_process
__all__ = ['ensure_running', 'register', 'unregister'] __all__ = ['ensure_running', 'register', 'unregister']

View File

@ -11,10 +11,8 @@ __all__ = [
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event' 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event'
] ]
import os
import threading import threading
import sys import sys
import itertools
import tempfile import tempfile
import _multiprocessing import _multiprocessing

View File

@ -7,8 +7,6 @@
# Licensed to PSF under a Contributor Agreement. # Licensed to PSF under a Contributor Agreement.
# #
import sys
import functools
import os import os
import itertools import itertools
import weakref import weakref

View File

@ -1085,7 +1085,6 @@ if _have_ssl:
# Test retrieval when run as a script. # Test retrieval when run as a script.
if __name__ == '__main__': if __name__ == '__main__':
import argparse import argparse
from email.utils import parsedate
parser = argparse.ArgumentParser(description="""\ parser = argparse.ArgumentParser(description="""\
nntplib built-in demo - display the latest articles in a newsgroup""") nntplib built-in demo - display the latest articles in a newsgroup""")

View File

@ -23,7 +23,7 @@ Misc variables:
""" """
from types import FunctionType, ModuleType from types import FunctionType
from copyreg import dispatch_table from copyreg import dispatch_table
from copyreg import _extension_registry, _inverted_registry, _extension_cache from copyreg import _extension_registry, _inverted_registry, _extension_cache
from itertools import islice from itertools import islice

View File

@ -503,7 +503,6 @@ def win32_ver(release='', version='', csd='', ptype=''):
# Import the needed APIs # Import the needed APIs
try: try:
import win32api
from win32api import RegQueryValueEx, RegOpenKeyEx, \ from win32api import RegQueryValueEx, RegOpenKeyEx, \
RegCloseKey, GetVersionEx RegCloseKey, GetVersionEx
from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \ from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \

View File

@ -66,7 +66,7 @@ import tokenize
import warnings import warnings
from collections import deque from collections import deque
from reprlib import Repr from reprlib import Repr
from traceback import extract_tb, format_exception_only from traceback import format_exception_only
# --------------------------------------------------------- common routines # --------------------------------------------------------- common routines

View File

@ -10,7 +10,6 @@ importers when locating support scripts as well as when importing modules.
# to implement PEP 338 (Executing Modules as Scripts) # to implement PEP 338 (Executing Modules as Scripts)
import os
import sys import sys
import importlib.machinery # importlib first so we can test #15386 via -m import importlib.machinery # importlib first so we can test #15386 via -m
import importlib.util import importlib.util

View File

@ -131,7 +131,6 @@ __version__ = "0.4"
import socket import socket
import select import select
import sys
import os import os
import errno import errno
try: try:

View File

@ -10,7 +10,7 @@
"""Internal support module for sre""" """Internal support module for sre"""
import _sre, sys import _sre
import sre_parse import sre_parse
from sre_constants import * from sre_constants import *
from _sre import MAXREPEAT from _sre import MAXREPEAT

View File

@ -12,8 +12,6 @@
# XXX: show string offset and offending character for all errors # XXX: show string offset and offending character for all errors
import sys
from sre_constants import * from sre_constants import *
from _sre import MAXREPEAT from _sre import MAXREPEAT

View File

@ -147,12 +147,9 @@ else:
if sys.platform == "win32": if sys.platform == "win32":
from _ssl import enum_certificates, enum_crls from _ssl import enum_certificates, enum_crls
from socket import getnameinfo as _getnameinfo
from socket import SHUT_RDWR as _SHUT_RDWR
from socket import socket, AF_INET, SOCK_STREAM, create_connection from socket import socket, AF_INET, SOCK_STREAM, create_connection
from socket import SOL_SOCKET, SO_TYPE from socket import SOL_SOCKET, SO_TYPE
import base64 # for DER-to-PEM translation import base64 # for DER-to-PEM translation
import traceback
import errno import errno

View File

@ -350,8 +350,6 @@ mswindows = (sys.platform == "win32")
import io import io
import os import os
import time import time
import traceback
import gc
import signal import signal
import builtins import builtins
import warnings import warnings

View File

@ -65,8 +65,6 @@ except NameError:
# from tarfile import * # from tarfile import *
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"] __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
from builtins import open as _open # Since 'open' is TarFile.open
#--------------------------------------------------------- #---------------------------------------------------------
# tar constants # tar constants
#--------------------------------------------------------- #---------------------------------------------------------

View File

@ -3,7 +3,6 @@
import sys as _sys import sys as _sys
import _thread import _thread
from time import sleep as _sleep
try: try:
from time import monotonic as _time from time import monotonic as _time
except ImportError: except ImportError:

View File

@ -35,8 +35,6 @@ if sys.platform == "win32":
# Attempt to configure Tcl/Tk without requiring PATH # Attempt to configure Tcl/Tk without requiring PATH
from tkinter import _fix from tkinter import _fix
import warnings
import _tkinter # If this fails your Python may not be configured for Tk import _tkinter # If this fails your Python may not be configured for Tk
TclError = _tkinter.TclError TclError = _tkinter.TclError
from tkinter.constants import * from tkinter.constants import *

View File

@ -27,7 +27,7 @@
# #
from tkinter import * from tkinter import *
from tkinter import _flatten, _cnfmerge, _default_root from tkinter import _cnfmerge, _default_root
# WARNING - TkVersion is a limited precision floating point number # WARNING - TkVersion is a limited precision floating point number
if TkVersion < 3.999: if TkVersion < 3.999:

View File

@ -32,7 +32,6 @@ import os
import shutil import shutil
import subprocess import subprocess
import sys import sys
import sysconfig
import types import types
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -134,7 +134,6 @@ from datetime import datetime
import http.client import http.client
import urllib.parse import urllib.parse
from xml.parsers import expat from xml.parsers import expat
import socket
import errno import errno
from io import BytesIO from io import BytesIO
try: try: