Improve type hinting in `synapse.util`.