Add type annotations, and fix issues found by mypy
The issues weren't noticed before because mypy does not analyze functions without an annotation in their signature.
Migrated from D7148 (view on Phabricator)
The issues weren't noticed before because mypy does not analyze functions without an annotation in their signature.
Migrated from D7148 (view on Phabricator)