Fix bySegment metrics de-serialization

Add typing hints to prevent need for unchecked