def __gt__(self, other: "FeatureState") -> bool:  # noqa: C901
        """
        Checks if the current feature state is higher priority that the provided feature state.

        :param other: (FeatureState) the feature state to compare the priority of
        :return: True if self is higher priority than other
        """
        if self.environment_id != other.environment_id:
            raise ValueError(
                "Cannot compare feature states as they belong to different environments."
            )

        if self.feature_id != other.feature_id:
            raise ValueError(
                "Cannot compare feature states as they belong to different features."
            )

        if self.identity_id:
            # identity is the highest priority so we can always return true
            if other.identity_id and self.identity_id != other.identity_id:
                raise ValueError(
                    "Cannot compare feature states as they are for different identities."
                )
            return True

        if (
            self.feature_segment_id
            and self.feature_segment_id != other.feature_segment_id
        ):
            # Return true if other_feature_state has a lower priority feature segment and not an identity overridden
            # flag, else False.
            return not (
                other.identity_id
                or (
                    other.feature_segment_id
                    and self.feature_segment < other.feature_segment  # type: ignore[operator]
                )
            )

        if self.type == other.type:
            if self.environment.use_v2_feature_versioning:  # type: ignore[union-attr]
                if (
                    self.environment_feature_version_id is None
                    or other.environment_feature_version_id is None
                ):
                    raise ValueError(
                        "Cannot compare feature states as they are missing environment_feature_version."
                    )

                return (  # type: ignore[no-any-return]
                    self.environment_feature_version > other.environment_feature_version  # type: ignore[operator]
                )
            else:
                # we use live_from here as a priority over the version since
                # the version is given when change requests are committed,
                # hence the version for a feature state that is scheduled
                # further in the future can be lower than a feature state
                # whose live_from value is earlier.
                # See: https://github.com/Flagsmith/flagsmith/issues/2030
                if self.is_live:
                    if not other.is_live or self.is_more_recent_live_from(other):
                        return True
                    elif (
                        self.live_from == other.live_from
                        and self._is_more_recent_version(other)
                    ):
                        return True

                return False

        # if we've reached here, then self is just the environment default. In this case, other is higher priority if
        # it has a feature_segment or an identity
        return not (other.feature_segment_id or other.identity_id)

        Checks if the current feature state is higher priority that the provided feature state.

        :param other: (FeatureState) the feature state to compare the priority of
        :return: True if self is higher priority than other
        
api/features/models.py