I have a python3.4 project and I recently decided to use mypy for better understanding.
This chunk of code works but checking with mypy pops out an error :
import zipfile
def zip_to_txt(zip: typing.IO[bytes]) -> BytesIO:
zz = zipfile.ZipFile(zip)
output = BytesIO()
for line, info in enumerate(zz.filelist):
date = "%d-%02d-%02d %02d:%02d:%02d" % info.date_time[:6]
output.write(str.encode("%-46s %s %12d\n" % (info.filename, date, info.file_size)))
output.seek(0, 0)
return output
The error :
PyPreviewGenerator/file_converter.py:170: error: "ZipFile" has no attribute "filelist" (corresponds to this line : for line, info in enumerate(zz.filelist):)
But when I look inside the ZipFile class, I can clearly see that the attribute exists.
So why does the error occurs ? and is there a way I can resolve it ?