| 1 | from _typeshed import StrPath |
| 2 | from collections.abc import Callable |
| 3 | from typing import Any, BinaryIO, Protocol, overload, type_check_only |
| 4 | |
| 5 | __all__ = ["what"] |
| 6 | |
| 7 | @type_check_only |
| 8 | class _ReadableBinary(Protocol): |
| 9 | def tell(self) -> int: ... |
| 10 | def read(self, size: int, /) -> bytes: ... |
| 11 | def seek(self, offset: int, /) -> Any: ... |
| 12 | |
| 13 | @overload |
| 14 | def what(file: StrPath | _ReadableBinary, h: None = None) -> str | None: ... |
| 15 | @overload |
| 16 | def what(file: Any, h: bytes) -> str | None: ... |
| 17 | |
| 18 | tests: list[Callable[[bytes, BinaryIO | None], str | None]] |