A local version of the Myers–Steenrod theorem