Repository: timothycrosley/isort
Pull request #567 (2017-06-06 06:09:41)

Feature/hotfix issue 565


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 76164afd..5f472f8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,10 @@
 Changelog
 =========
-### 4.2.13 - June 2, 2017 - hotfix release
+### 4.2.14 - June 2, 2017 - hotfix release
 IMPORTANT NOTE: This will be the last release with Python 2.6 support, subsequent releases will be 2.7+ only
+- Fixed #559 & #565: Added missing standard library imports
+
+### 4.2.13 - June 2, 2017 - hotfix release
 - Fixed #553: Check only and --diff now work together again
 
 ### 4.2.12 - June 1, 2017 - hotfix release
diff --git a/isort/settings.py b/isort/settings.py
index c60bd786..15cdb210 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -51,39 +51,51 @@ default = {'force_to_top': [],
            'sections': DEFAULT_SECTIONS,
            'no_sections': False,
            'known_future_library': ['__future__'],
-           'known_standard_library': ['BaseHTTPServer', 'ConfigParser', 'Cookie', 'EasyDialogs', 'Queue',
-                                      'SimpleXMLRPCServer', 'SocketServer', 'StringIO', '__builtin__', 'abc',
-                                      'aifc', 'anydbm', 'argparse', 'array', 'ast', 'asynchat', 'asyncio',
-                                      'asyncore', 'atexit', 'audioop', 'base64', 'bdb', 'binascii', 'binhex',
-                                      'bisect', 'builtins', 'bz2', 'cPickle', 'cProfile', 'cStringIO', 'calendar',
-                                      'cgi', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop',
-                                      'collections', 'colorsys', 'commands', 'compileall', 'concurrent', 'configparser',
-                                      'contextlib', 'copy', 'copyreg', 'crypt', 'csv', 'ctypes', 'curses', 'datetime',
-                                      'dbhash', 'dbm', 'decimal', 'difflib', 'dircache', 'dis', 'distutils', 'doctest',
-                                      'dumbdbm', 'dummy_threading', 'email', 'encodings', 'ensurepip', 'enum', 'errno',
-                                      'exceptions', 'faulthandler', 'fcntl', 'filecmp', 'fileinput', 'fnmatch',
-                                      'formatter', 'fpectl', 'fractions', 'ftplib', 'functools', 'gc', 'gdbm', 'getopt',
-                                      'getpass', 'gettext', 'glob', 'grp', 'gzip', 'hashlib', 'heapq', 'hmac', 'html',
-                                      'http', 'imaplib', 'imghdr', 'imp', 'importlib', 'inspect', 'io', 'ipaddress',
-                                      'itertools', 'json', 'keyword', 'lib2to3', 'linecache', 'locale', 'logging',
-                                      'lzma', 'macpath', 'mailbox', 'mailcap', 'marshal', 'math', 'mhlib', 'mimetypes',
-                                      'mmap', 'modulefinder', 'msilib', 'msvcrt', 'multiprocessing', 'netrc', 'nis',
-                                      'nntplib', 'numbers', 'operator', 'optparse', 'os', 'ossaudiodev', 'parser',
-                                      'pathlib', 'pdb', 'pickle', 'pickletools', 'pipes', 'pkgutil', 'platform',
-                                      'plistlib', 'poplib', 'posix', 'pprint', 'profile', 'pstats', 'pty', 'pwd',
-                                      'py_compile', 'pyclbr', 'pydoc', 'queue', 'quopri', 'random', 're', 'readline',
-                                      'reprlib', 'resource', 'rlcompleter', 'robotparser', 'runpy', 'sched', 'secrets',
-                                      'select', 'selectors', 'shelve', 'shlex', 'shutil', 'signal', 'site',
-                                      'sitecustomize', 'smtpd', 'smtplib', 'sndhdr', 'socket', 'socketserver',
-                                      'spwd', 'sqlite3', 'ssl', 'stat', 'statistics', 'string', 'stringprep',
-                                      'struct', 'subprocess', 'sunau', 'symbol', 'symtable', 'sys', 'sysconfig',
-                                      'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios', 'test',
-                                      'textwrap', 'thread', 'threading', 'time', 'timeit', 'tkinter', 'token',
-                                      'tokenize', 'trace', 'traceback', 'tracemalloc', 'tty', 'turtle', 'turtledemo',
-                                      'types', 'typing', 'unicodedata', 'unittest', 'urllib', 'urllib2', 'urlparse',
-                                      'usercustomize', 'uu', 'uuid', 'venv', 'warnings', 'wave', 'weakref',
-                                      'webbrowser', 'whichdb', 'winreg', 'winsound', 'wsgiref', 'xdrlib',
-                                      'xml', 'xmlrpc', 'xmlrpclib', 'zipapp', 'zipfile', 'zipimport', 'zlib'],
+           'known_standard_library': ['AL', 'BaseHTTPServer', 'Bastion', 'CGIHTTPServer', 'Carbon', 'ColorPicker',
+                                      'ConfigParser', 'Cookie', 'DEVICE', 'DocXMLRPCServer', 'EasyDialogs', 'FL',
+                                      'FrameWork', 'GL', 'HTMLParser', 'MacOS', 'MimeWriter', 'MiniAEFrame', 'Nav',
+                                      'PixMapWrapper', 'Queue', 'SUNAUDIODEV', 'ScrolledText', 'SimpleHTTPServer',
+                                      'SimpleXMLRPCServer', 'SocketServer', 'StringIO', 'Tix', 'Tkinter', 'UserDict',
+                                      'UserList', 'UserString', 'W', '__builtin__', 'abc', 'aepack', 'aetools',
+                                      'aetypes', 'aifc', 'al', 'anydbm', 'applesingle', 'argparse', 'array', 'ast',
+                                      'asynchat', 'asyncio', 'asyncore', 'atexit', 'audioop', 'autoGIL', 'base64',
+                                      'bdb', 'binascii', 'binhex', 'bisect', 'bsddb', 'buildtools', 'builtins',
+                                      'bz2', 'cPickle', 'cProfile', 'cStringIO', 'calendar', 'cd', 'cfmfile', 'cgi',
+                                      'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop', 'collections',
+                                      'colorsys', 'commands', 'compileall', 'compiler', 'concurrent', 'configparser',
+                                      'contextlib', 'cookielib', 'copy', 'copy_reg', 'copyreg', 'crypt', 'csv',
+                                      'ctypes', 'curses', 'datetime', 'dbhash', 'dbm', 'decimal', 'difflib',
+                                      'dircache', 'dis', 'distutils', 'dl', 'doctest', 'dumbdbm', 'dummy_thread',
+                                      'dummy_threading', 'email', 'encodings', 'ensurepip', 'enum', 'errno',
+                                      'exceptions', 'faulthandler', 'fcntl', 'filecmp', 'fileinput', 'findertools',
+                                      'fl', 'flp', 'fm', 'fnmatch', 'formatter', 'fpectl', 'fpformat', 'fractions',
+                                      'ftplib', 'functools', 'future_builtins', 'gc', 'gdbm', 'gensuitemodule',
+                                      'getopt', 'getpass', 'gettext', 'gl', 'glob', 'grp', 'gzip', 'hashlib',
+                                      'heapq', 'hmac', 'hotshot', 'html', 'htmlentitydefs', 'htmllib', 'http',
+                                      'httplib', 'ic', 'icopen', 'imageop', 'imaplib', 'imgfile', 'imghdr', 'imp',
+                                      'importlib', 'imputil', 'inspect', 'io', 'ipaddress', 'itertools', 'jpeg',
+                                      'json', 'keyword', 'lib2to3', 'linecache', 'locale', 'logging', 'lzma',
+                                      'macerrors', 'macostools', 'macpath', 'macresource', 'mailbox', 'mailcap',
+                                      'marshal', 'math', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'mimify', 'mmap',
+                                      'modulefinder', 'msilib', 'msvcrt', 'multifile', 'multiprocessing', 'mutex',
+                                      'netrc', 'new', 'nis', 'nntplib', 'numbers', 'operator', 'optparse', 'os',
+                                      'ossaudiodev', 'parser', 'pathlib', 'pdb', 'pickle', 'pickletools', 'pipes',
+                                      'pkgutil', 'platform', 'plistlib', 'popen2', 'poplib', 'posix', 'posixfile',
+                                      'pprint', 'profile', 'pstats', 'pty', 'pwd', 'py_compile', 'pyclbr', 'pydoc',
+                                      'queue', 'quopri', 'random', 're', 'readline', 'reprlib', 'resource', 'rexec',
+                                      'rfc822', 'rlcompleter', 'robotparser', 'runpy', 'sched', 'secrets', 'select',
+                                      'selectors', 'sets', 'sgmllib', 'sha', 'shelve', 'shlex', 'shutil', 'signal',
+                                      'site', 'sitecustomize', 'smtpd', 'smtplib', 'sndhdr', 'socket', 'socketserver',
+                                      'spwd', 'sqlite3', 'ssl', 'stat', 'statistics', 'statvfs', 'string', 'stringprep',
+                                      'struct', 'subprocess', 'sunau', 'sunaudiodev', 'symbol', 'symtable', 'sys',
+                                      'sysconfig', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios',
+                                      'test', 'textwrap', 'this', 'thread', 'threading', 'time', 'timeit', 'tkinter',
+                                      'token', 'tokenize', 'trace', 'traceback', 'tracemalloc', 'ttk', 'tty', 'turtle',
+                                      'turtledemo', 'types', 'typing', 'unicodedata', 'unittest', 'urllib', 'urllib2',
+                                      'urlparse', 'user', 'usercustomize', 'uu', 'uuid', 'venv', 'videoreader',
+                                      'warnings', 'wave', 'weakref', 'webbrowser', 'whichdb', 'winreg', 'winsound',
+                                      'wsgiref', 'xdrlib', 'xml', 'xmlrpc', 'xmlrpclib', 'zipapp', 'zipfile',
+                                      'zipimport', 'zlib'],
            'known_third_party': ['google.appengine.api'],
            'known_first_party': [],
            'multi_line_output': WrapModes.GRID,


Test patch:
diff --git a/test_isort.py b/test_isort.py
index 67eccc03..97f54f6f 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -745,12 +745,16 @@ def test_default_section():
 
 def test_first_party_overrides_standard_section():
     """Test to ensure changing the default section works as expected."""
-    test_input = ("import sys\n"
+    test_input = ("from HTMLParser import HTMLParseError, HTMLParser\n"
+                  "import sys\n"
                   "import os\n"
+                  "import this\n"
                   "import profile.test\n")
     test_output = SortImports(file_contents=test_input, known_first_party=['profile']).output
     assert test_output == ("import os\n"
                            "import sys\n"
+                           "import this\n"
+                           "from HTMLParser import HTMLParseError, HTMLParser\n"
                            "\n"
                            "import profile.test\n")