We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
TarFile.open
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All the code snippets in the following cases passed mypy . --strict but failed at runtime.
mypy . --strict
import tarfile with tarfile.open("filename.tar", "w", compresslevel=None) as tar: tar.add("readme.txt")
Traceback (most recent call last): File "c:\Users\raven\Documents\GitHub\tarfiletest\test.py", line 3, in <module> with tarfile.open("filename.tar", "w", compresslevel=None) as tar: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1844, in open return cls.taropen(name, mode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1854, in taropen return cls(name, mode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: TarFile.__init__() got an unexpected keyword argument 'compresslevel'
import tarfile with tarfile.open("filename.tar.gz", "w:gz", compresslevel=None) as tar: tar.add("readme.txt")
Traceback (most recent call last): File "c:\Users\raven\Documents\GitHub\tarfiletest\test.py", line 3, in <module> with tarfile.open("filename.tar.gz", "w:gz", compresslevel=None) as tar: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1822, in open return func(name, filemode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1870, in gzopen fileobj = GzipFile(name, mode + "b", compresslevel, fileobj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\gzip.py", line 220, in __init__ self.compress = zlib.compressobj(compresslevel, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object cannot be interpreted as an integer
import tarfile with tarfile.open("filename.tar.xz", "w:xz", compresslevel=None) as tar: tar.add("readme.txt")
Traceback (most recent call last): File "c:\Users\raven\Documents\GitHub\tarfiletest\test.py", line 3, in <module> with tarfile.open("filename.tar.xz", "w:xz", compresslevel=None) as tar: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1822, in open return func(name, filemode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1933, in xzopen t = cls.taropen(name, mode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1854, in taropen return cls(name, mode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: TarFile.__init__() got an unexpected keyword argument 'compresslevel'
import tarfile with tarfile.open("filename.tar.bz2", "w:bz2", compresslevel=None) as tar: tar.add("readme.txt")
Traceback (most recent call last): File "c:\Users\raven\Documents\GitHub\tarfiletest\test.py", line 3, in <module> with tarfile.open("filename.tar.bz2", "w:bz2", compresslevel=None) as tar: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1822, in open return func(name, filemode, fileobj, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\tarfile.py", line 1902, in bz2open fileobj = BZ2File(fileobj or name, mode, compresslevel=compresslevel) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raven\AppData\Local\Programs\Python\Python312\Lib\bz2.py", line 59, in __init__ if not (1 <= compresslevel <= 9): ^^^^^^^^^^^^^^^^^^^^^^^ TypeError: '<=' not supported between instances of 'int' and 'NoneType'
The text was updated successfully, but these errors were encountered:
Possibly fixed by #12181.
Sorry, something went wrong.
No branches or pull requests
All the code snippets in the following cases passed
mypy . --strict
but failed at runtime.Case 1
Case 2
Case 3
Case 4
The text was updated successfully, but these errors were encountered: