(self, other: "SchemaRange")
return False
Returns None if the resulting region is impossible.
        Returns True if the other constraint was completely subtracted from
        self.  If it could not be, then it returns False (and the caller should probably
        keep the other constraint as a negated constraint)
Returns None if the resulting region is impossible.
        Returns True if the other constraint was completely subtracted from
        self.  If it could not be, then it returns False (and the caller should probably
        keep the other constraint as a negated constraint)
Returns None if the resulting region is impossible . Returns True if the other constraint was completely subtracted from self . If it could not be then it returns False ( and the caller should probably keep the other constraint as a negated constraint )
def diff(self, other: "SchemaRange") -> Optional[bool]:
        """Returns None if the resulting region is impossible.
        Returns True if the other constraint was completely subtracted from
        self.  If it could not be, then it returns False (and the caller should probably
        keep the other constraint as a negated constraint)
        """
        # for now, just handle simple exclusions
        if not other.is_integer or other.is_integer == self.is_integer:
            # the exclusion is less than the actual range
            if (
                self.minimum is not None
                and other.maximum is not None
                and (
                    other.maximum < self.minimum
                    or (
                        other.maximum == self.minimum
                        and (self.exclusive_minimum or other.exclusive_maximum)
                    )
                )
            ):
                return True
            # the exclusion is greater than the actual range
            if (
                self.maximum is not None
                and other.minimum is not None
                and (
                    other.minimum > self.maximum
                    or (
                        other.minimum == self.maximum
                        and (self.exclusive_maximum or other.exclusive_minimum)
                    )
                )
            ):
                return True

            if other.minimum is None:
                if self.minimum is None:
                    # the exclusion and the range have no minimum
                    if other.maximum is None:
                        # nothing is possible
                        return None
                    else:
                        self.minimum = other.maximum
                        self.exclusive_minimum = not other.exclusive_maximum
                        return True
                # else might create a hole, so avoid this case
            else:
                # ASSERT: other.minimum is not None
                if (
                    self.minimum is None
                    or self.minimum < other.minimum
                    or (
                        self.minimum == other.minimum
                        and (not self.exclusive_minimum or other.exclusive_minimum)
                    )
                ):
                    if (
                        other.maximum is None
                        or self.maximum is not None
                        and (
                            other.maximum > self.maximum
                            or (
                                (
                                    other.maximum == self.maximum
                                    and (
                                        not other.exclusive_maximum
                                        or self.exclusive_maximum
                                    )
                                )
                            )
                        )
                    ):
                        self.maximum = other.minimum
                        self.exclusive_maximum = not other.exclusive_minimum
                        return True
                    # else might create a hole, so avoid this case
                else:
                    # self.minimum >= other.minimum
                    if (
                        other.maximum is None
                        or self.maximum < other.maximum
                        or (
                            self.maximum == other.maximum
                            and (not other.exclusive_maximum or self.exclusive_maximum)
                        )
                    ):
                        # nothing is possible
                        return None
                    else:
                        self.minimum = other.maximum
                        self.exclusive_minimum = not other.exclusive_maximum
                        return True

            if other.maximum is None:
                if self.maximum is None:
                    # the exclusion and the range have no maximum
                    if other.minimum is None:
                        # nothing is possible
                        return None
                    else:
                        self.maximum = other.minimum
                        self.exclusive_maximum = not other.exclusive_minimum
                        return True
                # else might create a hole, so avoid this case
            else:
                # ASSERT: other.maximum is not None
                if (
                    self.maximum is None
                    or self.maximum > other.maximum
                    or (
                        self.maximum == other.maximum
                        and (not self.exclusive_maximum or other.exclusive_maximum)
                    )
                ):
                    if (
                        other.minimum is None
                        or self.minimum is not None
                        and (
                            other.minimum < self.minimum
                            or (
                                (
                                    other.minimum == self.minimum
                                    and (
                                        not other.exclusive_minimum
                                        or self.exclusive_minimum
                                    )
                                )
                            )
                        )
                    ):
                        self.minimum = other.maximum
                        self.exclusive_minimum = not other.exclusive_maximum
                        return True
                    # else might create a hole, so avoid this case
                else:
                    # self.maximum >= other.maximum
                    if (
                        other.minimum is None
                        or self.minimum > other.minimum
                        or (
                            self.minimum == other.minimum
                            and (not other.exclusive_minimum or self.exclusive_minimum)
                        )
                    ):
                        # nothing is possible
                        return None
                    else:
                        self.maximum = other.minimum
                        self.exclusive_maximum = not other.exclusive_minimum
                        return True
        return False
def diff ( self , other : "SchemaRange" ) -> Optional [ bool ] : # for now, just handle simple exclusions if not other . is_integer or other . is_integer == self . is_integer : # the exclusion is less than the actual range if ( self . minimum is not None and other . maximum is not None and ( other . maximum < self . minimum or ( other . maximum == self . minimum and ( self . exclusive_minimum or other . exclusive_maximum ) ) ) ) : return True # the exclusion is greater than the actual range if ( self . maximum is not None and other . minimum is not None and ( other . minimum > self . maximum or ( other . minimum == self . maximum and ( self . exclusive_maximum or other . exclusive_minimum ) ) ) ) : return True if other . minimum is None : if self . minimum is None : # the exclusion and the range have no minimum if other . maximum is None : # nothing is possible return None else : self . minimum = other . maximum self . exclusive_minimum = not other . exclusive_maximum return True # else might create a hole, so avoid this case else : # ASSERT: other.minimum is not None if ( self . minimum is None or self . minimum < other . minimum or ( self . minimum == other . minimum and ( not self . exclusive_minimum or other . exclusive_minimum ) ) ) : if ( other . maximum is None or self . maximum is not None and ( other . maximum > self . maximum or ( ( other . maximum == self . maximum and ( not other . exclusive_maximum or self . exclusive_maximum ) ) ) ) ) : self . maximum = other . minimum self . exclusive_maximum = not other . exclusive_minimum return True # else might create a hole, so avoid this case else : # self.minimum >= other.minimum if ( other . maximum is None or self . maximum < other . maximum or ( self . maximum == other . maximum and ( not other . exclusive_maximum or self . exclusive_maximum ) ) ) : # nothing is possible return None else : self . minimum = other . maximum self . exclusive_minimum = not other . exclusive_maximum return True if other . maximum is None : if self . maximum is None : # the exclusion and the range have no maximum if other . minimum is None : # nothing is possible return None else : self . maximum = other . minimum self . exclusive_maximum = not other . exclusive_minimum return True # else might create a hole, so avoid this case else : # ASSERT: other.maximum is not None if ( self . maximum is None or self . maximum > other . maximum or ( self . maximum == other . maximum and ( not self . exclusive_maximum or other . exclusive_maximum ) ) ) : if ( other . minimum is None or self . minimum is not None and ( other . minimum < self . minimum or ( ( other . minimum == self . minimum and ( not other . exclusive_minimum or self . exclusive_minimum ) ) ) ) ) : self . minimum = other . maximum self . exclusive_minimum = not other . exclusive_maximum return True # else might create a hole, so avoid this case else : # self.maximum >= other.maximum if ( other . minimum is None or self . minimum > other . minimum or ( self . minimum == other . minimum and ( not other . exclusive_minimum or self . exclusive_minimum ) ) ) : # nothing is possible return None else : self . maximum = other . minimum self . exclusive_maximum = not other . exclusive_minimum return True return False