Skip to content

PySet::empty could be infallible #6074

@anuraaga

Description

@anuraaga

Currently PySet::empty() returns PyResult<Bound<'_, PySet>>, though AFAIK, this operation can't fail. Or at least it can't fail any more likely than PyDict::new(py) which does not return PyResult. I was initially confused since I was populating an empty set and dict to the same struct.

On the flip side, I understand that PySet::empty is being consistent with PySet::new, which needs to return error for unhashable items. So there is a consistency argument to be made, but in general I guess infallible methods should not return PyResult?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions