Tighten up a couple of type annotations

These functions never return null so mark their return types as non-nullable.
Merge pull request #521 from MatrixFrog/patch-1

Tighten up a couple of type annotations