Add some type hints

A couple of these were getting hit pretty hard in our setup, so I think they're worthwhile. The tests don't pass, but they fail the same way as at 0f97795.