Python fixes: resolve new mypy warnings and pin some tool versions.
We may need to refine these over time, but they should be good enough for now.
Fixes #1788 (closed) .
We may need to refine these over time, but they should be good enough for now.
Fixes #1788 (closed) .