Various typing fixes
Crucially this adds --check-untyped-defs
to the mypy check which hopefully means changes like 7fce8005 won't be missed in future refactors.
Crucially this adds --check-untyped-defs
to the mypy check which hopefully means changes like 7fce8005 won't be missed in future refactors.