Python3 annotations

As the commits will testify, this is not my work, I'm only the janitor here :-)

I've brought in @jlowin's Python 3 annotations work, merged some conflicts, and re-added some code that got dropped during the merge.
This seems like it's specific to dispatching, not a general python2/3 compatibility issue.  I'd suggest moving this into dispatcher.py or something.