<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def contains(self, other):
 """ Return True if this contains other. Other may be either range of same type or scalar of same type as the boundaries. True True False True False Contains can also be called using the ``in`` operator. True This is the same as the ``self @> other`` in PostgreSQL. :param other: Object to be checked whether it exists within this range or not. :return: ``True`` if `other` is completely within this range, otherwise ``False``. :raises TypeError: If `other` is not of the correct type. """


        if self.is_valid_range(other):
            if not self:
                return not other
            elif not other or other.startsafter(self) and other.endsbefore(self):
                return True
            else:
                return False
        elif self.is_valid_scalar(other):
            # If the lower bounary is not unbound we can safely perform the
            # comparison. Otherwise we'll try to compare a scalar to None, which
            # is bad
            is_within_lower = True
            if not self.lower_inf:
                lower_cmp = operator.le if self.lower_inc else operator.lt
                is_within_lower = lower_cmp(self.lower, other)

            # If the upper bounary is not unbound we can safely perform the
            # comparison. Otherwise we'll try to compare a scalar to None, which
            # is bad
            is_within_upper = True
            if not self.upper_inf:
                upper_cmp = operator.ge if self.upper_inc else operator.gt
                is_within_upper = upper_cmp(self.upper, other)

            return is_within_lower and is_within_upper
        else:
            raise TypeError(
                "Unsupported type to test for inclusion '{0.__class__.__name__}'".format(
                    other))