Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/gzip.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
import zlib
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer
from io import FileIO, TextIOWrapper
from typing import Final, Literal, Protocol, TypeAlias, overload, type_check_only
from typing import IO, Final, Literal, Protocol, TypeAlias, overload, type_check_only
from typing_extensions import deprecated

if sys.version_info >= (3, 14):
Expand Down Expand Up @@ -90,9 +90,9 @@ class _PaddedFile:

class BadGzipFile(OSError): ...

class GzipFile(BaseStream):
class GzipFile(BaseStream, IO[bytes]):
myfileobj: FileIO | None
mode: object
mode: object # type: ignore[assignment] # value is actually READ/WRITE (int), not str as in IO[bytes]
name: str
compress: zlib._Compress
fileobj: _ReadableFileobj | _WritableFileobj
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -2310,3 +2310,12 @@ type Alias[T] = list[T]
def g[T = int](x: T) -> T: ...
[out]
_testNativeParserPEP695InStubNoVersionError.py:3: note: Revealed type is "def [T] (x: T) -> T"

[case testOverloadedGzipOpenAssignableToCallableReturningIO_Issue21784]
# https://github.com/python/mypy/issues/21784
from collections.abc import Callable
from typing import IO
import gzip

foo: Callable[[str, str], IO] = gzip.open
[out]
Loading