Skip to content

GzipFile not allowed for tarfile.open(fileobj=...) #5491

Closed
@asottile

Description

@asottile

minimal reproduction:

import gzip
import tarfile


open('t', 'w').close()
with gzip.GzipFile('out.tar.gz', 'wb') as gzipf:
    with tarfile.open(fileobj=gzipf, mode='w') as tf:
        tf.add('t')
$ python3 t.py 
$ mypy t.py
t.py:7: error: Argument "fileobj" to "open" has incompatible type "GzipFile"; expected "Optional[IO[bytes]]"
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.812

presumably fileobj should use a Protocol of some shape ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: ioI/O related issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions