Add typing to detect_metadata() and related functions
This also moves the call to detect_metadata() to
translate_directory_intrinsic_metadata so type annotations make more
sense; and remove a dead/broken code branch in
DirectoryMetadataIndexer.index() that was detected by mypy.