Skip to content

Commit 055d1ed

Browse files
committed
Fix mypy
1 parent e108de8 commit 055d1ed

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

arpy.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,11 @@ def open(self, name: Union[bytes,ArchiveFileHeader]) -> ArchiveFileData:
421421

422422
raise ValueError("Can't look up file using type %s, expected bytes or ArchiveFileHeader" % (type(name),))
423423

424-
def extract(self, member: bytes, path=None):
424+
def extract(self, member: bytes, path: Optional[Union[str,bytes]]=None) -> None:
425425
filename = os.path.basename(member)
426+
if path is None:
427+
path = os.getcwd()
428+
426429
if isinstance(path, bytes):
427430
filepath = os.path.join(path, filename)
428431
else:
@@ -437,15 +440,15 @@ def extract(self, member: bytes, path=None):
437440
break
438441
f.write(buffer)
439442

440-
def extractall(self, path: Union[str, bytes], members: Optional[List[bytes]]=None):
443+
def extractall(self, path: Union[str, bytes], members: Optional[List[bytes]]=None) -> None:
441444
self.read_all_headers()
442445

443446
normpath = os.path.normpath(path)
444447
if isinstance(normpath, str):
445448
normpath = normpath.encode('utf-8')
446449

447450
if members is None:
448-
sources = self.archived_files.keys()
451+
sources = list(self.archived_files.keys())
449452
else:
450453
sources = members
451454

@@ -456,7 +459,7 @@ def extractall(self, path: Union[str, bytes], members: Optional[List[bytes]]=Non
456459
norm_filepath = os.path.normpath(filepath)
457460

458461
if os.path.commonpath([normpath, norm_filepath]) != normpath:
459-
raise ExtractBreakoutAttempt("file %s would be extracted below specified path" % (member,))
462+
raise ExtractBreakoutAttempt("file %r would be extracted below specified path" % (member,))
460463

461464
norm_dirpath = os.path.normpath(os.path.join(normpath, member_dir))
462465
os.makedirs(norm_dirpath, exist_ok=True)

0 commit comments

Comments
 (0)