Add type annotations to metadata mappings (T2259)
This patch adds type annotations to metadata mappings so that the mypy
type checker can detect bugs in code. While working on the path, I also
encountered these issues:
- mypy raises error on detecting for implicit None returns, so I had to add return None at many places.
- At a few places, @property s' are accessed using cls. mypy rightfully raises an error, so I had to add ignore to silence it for now. It appears Python 3.9+ supports class level properties so the ignores could be replaced by the proper handling when the minimum python version is raised.
Closes T2259.