def endsbefore(self, other):
        """
        Test if this range ends before `other`. `other` may be either range or
        scalar. This only takes the upper end of the ranges into consideration.
        If the scalar or the upper end of the given range is less than or equal
        to this range's upper end, ``True`` is returned.

            >>> intrange(1, 5).endsbefore(5)
            True
            >>> intrange(1, 5).endsbefore(intrange(1, 5))
            True

        :param other: Range or scalar to test.
        :return: ``True`` if this range ends before `other`, otherwise ``False``
        :raises TypeError: If `other` is of the wrong type.
        """

        if self.is_valid_range(other):
            if self.upper == other.upper:
                return not self.upper_inc or other.upper_inc
            elif self.upper_inf:
                return False
            elif other.upper_inf:
                return True
            else:
                return self.upper <= other.upper
        elif self.is_valid_scalar(other):
            return self.upper <= other
        else:
            raise TypeError(
                "Unsupported type to test for ends before '{}'".format(
                    other.__class__.__name__))
Test if this range ends before `other`. `other` may be either range or
        scalar. This only takes the upper end of the ranges into consideration.
        If the scalar or the upper end of the given range is less than or equal
        to this range's upper end, ``True`` is returned.

            >>> intrange(1, 5).endsbefore(5)
            True
            >>> intrange(1, 5).endsbefore(intrange(1, 5))
            True

        :param other: Range or scalar to test.
        :return: ``True`` if this range ends before `other`, otherwise ``False``
        :raises TypeError: If `other` is of the wrong type.