TYP: make IOHandles generic
Towards #41610

This doesn't help with any ignore statements, as `Buffer` is defined as `Buffer = Union[IO[AnyStr], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]`: `IO[AnyStr]` will be replaced with `IO[str]` or `IO[bytes]`.

btw., `Buffer` is a "bad" union as it contains one generic and many actual types (I think, I'm the one to blame for that). It is often used without an actual type (`Buffer` instead of `Buffer[str]` or `Buffer[bytes]`).