mirror of https://github.com/pypa/pip
Assert not None instead of if check
This commit is contained in:
parent
ea7a7d26fc
commit
50cbd6a032
|
@ -33,9 +33,9 @@ def auto_decode(data):
|
|||
for line in data.split(b'\n')[:2]:
|
||||
if line[0:1] == b'#' and ENCODING_RE.search(line):
|
||||
result = ENCODING_RE.search(line)
|
||||
if result:
|
||||
encoding = result.groups()[0].decode('ascii')
|
||||
return data.decode(encoding)
|
||||
assert result is not None
|
||||
encoding = result.groups()[0].decode('ascii')
|
||||
return data.decode(encoding)
|
||||
return data.decode(
|
||||
locale.getpreferredencoding(False) or sys.getdefaultencoding(),
|
||||
)
|
||||
|
|
|
@ -205,7 +205,6 @@ def untar_file(filename, location):
|
|||
)
|
||||
continue
|
||||
else:
|
||||
fp = None
|
||||
try:
|
||||
fp = tar.extractfile(member)
|
||||
except (KeyError, AttributeError) as exc:
|
||||
|
@ -217,11 +216,10 @@ def untar_file(filename, location):
|
|||
)
|
||||
continue
|
||||
ensure_dir(os.path.dirname(path))
|
||||
assert fp is not None
|
||||
with open(path, 'wb') as destfp:
|
||||
if fp:
|
||||
shutil.copyfileobj(fp, destfp)
|
||||
if fp:
|
||||
fp.close()
|
||||
shutil.copyfileobj(fp, destfp)
|
||||
fp.close()
|
||||
# Update the timestamp (useful for cython compiled files)
|
||||
# https://github.com/python/typeshed/issues/2673
|
||||
tar.utime(member, path) # type: ignore
|
||||
|
|
Loading…
Reference in New Issue