Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54540ec

Browse files
committed
Remove redundant imports.
1 parent c53ae58 commit 54540ec

7 files changed

Lines changed: 6 additions & 12 deletions

File tree

Lib/getpass.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def unix_getpass(prompt='Password: ', stream=None):
7272
finally:
7373
termios.tcsetattr(fd, tcsetattr_flags, old)
7474
stream.flush() # issue7208
75-
except termios.error as e:
75+
except termios.error:
7676
if passwd is not None:
7777
# _raw_input succeeded. The final tcsetattr failed. Reraise
7878
# instead of leaving the terminal in an unknown state.
@@ -145,8 +145,6 @@ def getuser():
145145
146146
"""
147147

148-
import os
149-
150148
for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
151149
user = os.environ.get(name)
152150
if user:

Lib/pickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ def _test():
13261326
return doctest.testmod()
13271327

13281328
if __name__ == "__main__":
1329-
import sys, argparse
1329+
import argparse
13301330
parser = argparse.ArgumentParser(
13311331
description='display contents of the pickle files')
13321332
parser.add_argument(

Lib/pstats.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,6 @@ def postcmd(self, stop, line):
674674
return stop
675675
return None
676676

677-
import sys
678677
if len(sys.argv) > 1:
679678
initprofile = sys.argv[1]
680679
else:

Lib/shutil.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
try:
1717
import bz2
18+
del bz2
1819
_BZ2_SUPPORTED = True
1920
except ImportError:
2021
_BZ2_SUPPORTED = False

Lib/site.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def addpackage(sitedir, name, known_paths):
154154
if not dircase in known_paths and os.path.exists(dir):
155155
sys.path.append(dir)
156156
known_paths.add(dircase)
157-
except Exception as err:
157+
except Exception:
158158
print("Error processing line {:d} of {}:\n".format(n+1, fullname),
159159
file=sys.stderr)
160160
for record in traceback.format_exception(*sys.exc_info()):
@@ -241,7 +241,6 @@ def getusersitepackages():
241241
return USER_SITE
242242

243243
from sysconfig import get_path
244-
import os
245244

246245
if sys.platform == 'darwin':
247246
from sysconfig import get_config_var

Lib/tkinter/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,6 @@ def getint_event(s):
11591159
return (e,)
11601160
def _report_exception(self):
11611161
"""Internal function."""
1162-
import sys
11631162
exc, val, tb = sys.exc_info()
11641163
root = self._root()
11651164
root.report_callback_exception(exc, val, tb)
@@ -1663,7 +1662,7 @@ def __init__(self, screenName=None, baseName=None, className='Tk',
16631662
# ensure that self.tk is always _something_.
16641663
self.tk = None
16651664
if baseName is None:
1666-
import sys, os
1665+
import os
16671666
baseName = os.path.basename(sys.argv[0])
16681667
baseName, ext = os.path.splitext(baseName)
16691668
if ext not in ('.py', '.pyc', '.pyo'):
@@ -1737,7 +1736,7 @@ def readprofile(self, baseName, className):
17371736
exec(open(base_py).read(), dir)
17381737
def report_callback_exception(self, exc, val, tb):
17391738
"""Internal function. It reports exception on sys.stderr."""
1740-
import traceback, sys
1739+
import traceback
17411740
sys.stderr.write("Exception in Tkinter callback\n")
17421741
sys.last_type = exc
17431742
sys.last_value = val

Lib/tkinter/filedialog.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ def _fixoptions(self):
306306
def _fixresult(self, widget, result):
307307
if result:
308308
# keep directory and filename until next time
309-
import os
310309
# convert Tcl path objects to strings
311310
try:
312311
result = result.string
@@ -333,7 +332,6 @@ def _fixresult(self, widget, result):
333332
# multiple results:
334333
result = tuple([getattr(r, "string", r) for r in result])
335334
if result:
336-
import os
337335
path, file = os.path.split(result[0])
338336
self.options["initialdir"] = path
339337
# don't set initialfile or filename, as we have multiple of these

0 commit comments

Comments
 (0)