pycompat type hints
The statprof
(and maybe the IOError subscripting) changes fix actual bugs, but I figure it's better to graft them to stable after this lands, so there are breadcrumbs to the typing that surfaced them and so we don't have to fool around with splitting up the stack and waiting for stable to be merged back into default.