pmb: Misc fixes
See individual commits. There is little cohesion among the commits, so I don't think there's any good way to summarise them. E.g., I added the unit tests to give me confidence that my changes in version.py wouldn't break anything, and since I had written the tests for that anyway I thought I might as well commit them.
But, most remarkably, with this the entire codebase is fully type hinted! (apart from unit tests and ignored lines)