Skip to content

Commit

Permalink
typing: have readers/writers inherit from BinaryIO
Browse files Browse the repository at this point in the history
This gives type checkers more awareness. And it will catch issues
if our classes ever diverge from what the IO interface dictates.
  • Loading branch information
indygreg committed Dec 26, 2020
1 parent a34abc9 commit ab8d698
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions zstandard/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# of the BSD license. See the LICENSE file for details.

from typing import (
BinaryIO,
ByteString,
Generator,
IO,
Expand Down Expand Up @@ -209,7 +210,7 @@ class ZstdCompressionChunker(object):
def flush(self): ...
def finish(self): ...

class ZstdCompressionReader(object):
class ZstdCompressionReader(BinaryIO):
def __enter__(self) -> "ZstdCompressionReader": ...
def __exit__(self, exc_type, exc_value, exc_tb): ...
def readable(self) -> bool: ...
Expand All @@ -234,7 +235,7 @@ class ZstdCompressionReader(object):
def readinto(self, b) -> int: ...
def readinto1(self, b) -> int: ...

class ZstdCompressionWriter(object):
class ZstdCompressionWriter(BinaryIO):
def __enter__(self) -> "ZstdCompressionWriter": ...
def __exit__(self, exc_type, exc_value, exc_tb): ...
def memory_size(self) -> int: ...
Expand Down Expand Up @@ -316,7 +317,7 @@ class ZstdDecompressionObj(object):
def decompress(self, data: ByteString) -> bytes: ...
def flush(self, length: int = 0): ...

class ZstdDecompressionReader(object):
class ZstdDecompressionReader(BinaryIO):
def __enter__(self) -> "ZstdDecompressionReader": ...
def __exit__(self, exc_type, exc_value, exc_tb): ...
def readable(self) -> bool: ...
Expand All @@ -342,7 +343,7 @@ class ZstdDecompressionReader(object):
def readinto1(self, b) -> int: ...
def seek(self, pos: int, whence: int = 0) -> int: ...

class ZstdDecompressionWriter(object):
class ZstdDecompressionWriter(BinaryIO):
def __enter__(self) -> "ZstdDecompressionWriter": ...
def __exit__(self, exc_type, exc_value, exc_tb): ...
def memory_size(self) -> int: ...
Expand Down

0 comments on commit ab8d698

Please sign in to comment.