It's not immediately clear where does the `AttributeError` comes from, maybe make the comment more explicit?