Skip to content

Commit 4b42ff6

Browse files
committed
unused imports, pep8
1 parent 6f73874 commit 4b42ff6

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _r_long(int_bytes):
6969
def _path_join(*args):
7070
"""Replacement for os.path.join."""
7171
return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x
72-
for x in args if x)
72+
for x in args if x)
7373

7474

7575
def _path_exists(path):
@@ -406,14 +406,16 @@ def _bytes_from_bytecode(self, fullname, data, source_stats):
406406
pass
407407
else:
408408
if _r_long(raw_timestamp) != source_mtime:
409-
raise ImportError("bytecode is stale for {}".format(fullname))
409+
raise ImportError(
410+
"bytecode is stale for {}".format(fullname))
410411
try:
411412
source_size = source_stats['size'] & 0xFFFFFFFF
412413
except KeyError:
413414
pass
414415
else:
415416
if _r_long(raw_size) != source_size:
416-
raise ImportError("bytecode is stale for {}".format(fullname))
417+
raise ImportError(
418+
"bytecode is stale for {}".format(fullname))
417419
# Can't return the code object as errors from marshal loading need to
418420
# propagate even when source is available.
419421
return data[12:]
@@ -519,7 +521,7 @@ def get_code(self, fullname):
519521
code_object = compile(source_bytes, source_path, 'exec',
520522
dont_inherit=True)
521523
if (not sys.dont_write_bytecode and bytecode_path is not None and
522-
source_mtime is not None):
524+
source_mtime is not None):
523525
# If e.g. Jython ever implements imp.cache_from_source to have
524526
# their own cached file format, this block of code will most likely
525527
# throw an exception.
@@ -890,7 +892,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
890892

891893
def _resolve_name(name, package, level):
892894
"""Resolve a relative module name to an absolute one."""
893-
bits = package.rsplit('.', level-1)
895+
bits = package.rsplit('.', level - 1)
894896
if len(bits) < level:
895897
raise ValueError('attempted relative import beyond top-level package')
896898
base = bits[0]
@@ -1010,7 +1012,7 @@ def _handle_fromlist(module, fromlist, import_):
10101012
fromlist = list(fromlist)
10111013
fromlist.remove('*')
10121014
fromlist.extend(module.__all__)
1013-
for x in (y for y in fromlist if not hasattr(module,y)):
1015+
for x in (y for y in fromlist if not hasattr(module, y)):
10141016
try:
10151017
import_('{0}.{1}'.format(module.__name__, x))
10161018
except ImportError:

Lib/importlib/abc.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
"""Abstract base classes related to import."""
22
from . import _bootstrap
33
from . import machinery
4-
from . import util
54
import abc
65
import imp
7-
import io
86
import marshal
9-
import os.path
107
import sys
118
import tokenize
12-
import types
139
import warnings
1410

1511

@@ -256,15 +252,17 @@ def get_code(self, fullname):
256252
try:
257253
magic = data[:4]
258254
if len(magic) < 4:
259-
raise ImportError("bad magic number in {}".format(fullname))
255+
raise ImportError(
256+
"bad magic number in {}".format(fullname))
260257
raw_timestamp = data[4:8]
261258
if len(raw_timestamp) < 4:
262259
raise EOFError("bad timestamp in {}".format(fullname))
263260
pyc_timestamp = _bootstrap._r_long(raw_timestamp)
264261
bytecode = data[8:]
265262
# Verify that the magic number is valid.
266263
if imp.get_magic() != magic:
267-
raise ImportError("bad magic number in {}".format(fullname))
264+
raise ImportError(
265+
"bad magic number in {}".format(fullname))
268266
# Verify that the bytecode is not stale (only matters when
269267
# there is source to fall back on.
270268
if source_timestamp:

0 commit comments

Comments
 (0)