Commits

Steven Silvester  committed 7f336b5

Added support for multiline imports using '('

  • Participants
  • Parent commits c747d3f

Comments (0)

Files changed (2)

File lib3to2/fixes/fix_imports.py

 # helps match 'client.HTTPConnection', if 'client' has been imported from http
 power_subname_match = "power< {fmt_attr} any* >"
 # helps match 'from http.client import HTTPConnection'
-from_import_match = "from_import=import_from< 'from' {fmt_name} 'import' imported=any >"
+from_import_match = "from_import=import_from< 'from' {fmt_name} 'import' ['('] imported=any [')]>"
 # helps match 'from http import client'
 from_import_submod_match = "from_import_submod=import_from< 'from' {fmt_name} 'import' ({fmt_attr} | import_as_name< {fmt_attr} 'as' renamed=any > | import_as_names< any* ({fmt_attr} | import_as_name< {fmt_attr} 'as' renamed=any >) any* > ) >"
 # helps match 'import urllib.request'

File lib3to2/tests/test_imports.py

         b = "from builtins import open"
         a = "from __builtin__ import open"
         self.check(b, a)
-
+        
+        b = """from SocketServer import (ThreadingUDPServer, DatagramRequestHandler,
+                          ThreadingTCPServer, StreamRequestHandler)"""
+        a = """from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
+                          ThreadingTCPServer, StreamRequestHandler)"""
+        self.check(b, a)
+        
     def test_dotted_names_quad(self):
 
         b = "import    html.parser as spam,  math,     tkinter.__init__,   dbm.gnu #comment!"