Format: application/octet-stream
1 import os
2 import sys
3 from typing import Any, BinaryIO, Callable, List, Optional, Protocol, Text, Union, overload
4
5 class _ReadableBinary(Protocol):
6 def tell(self) -> int: ...
7 def read(self, size: int) -> bytes: ...
8 def seek(self, offset: int) -> Any: ...
9
10 if sys.version_info >= (3, 6):
11 _File = Union[Text, os.PathLike[Text], _ReadableBinary]
12 else:
13 _File = Union[Text, _ReadableBinary]
14
15 @overload
16 def what(file: _File, h: None = ...) -> Optional[str]: ...
17 @overload
18 def what(file: Any, h: bytes) -> Optional[str]: ...
19
20 tests: List[Callable[[bytes, Optional[BinaryIO]], Optional[str]]]
21