Skip to content

harborapi.models.mappings

Custom mapping types.

FirstDict

Dict with method to get its first value.

Source code in harborapi/models/mappings.py
class FirstDict(OrderedDict[_KT, _VT]):
    """Dict with method to get its first value."""

    def first(self) -> Optional[_VT]:
        """Return the first value in the dict or None if dict is empty."""
        return next(iter(self.values()), None)

first()

Return the first value in the dict or None if dict is empty.

Source code in harborapi/models/mappings.py
def first(self) -> Optional[_VT]:
    """Return the first value in the dict or None if dict is empty."""
    return next(iter(self.values()), None)