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]`).
Hello @twoertwein! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:

















There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2021-11-14 03:38:45 UTC #43951 is a follow-up to this PR that also contains this PR. If #43951 isn't too large to review (it is large), I wouldn't mind simply skipping this PR. lgtm @simonjayhawkins if any comments can you merge merge master and can get this in @jreback  green'ish thanks @twoertwein 