def write_sync_state(self, leader: Optional[str], sync_standby: Optional[Collection[str]],
                         quorum: Optional[int], version: Optional[str] = None) -> Optional[SyncState]:
        """Prepare and write annotations to $SCOPE-sync Endpoint or ConfigMap.

        :param leader: name of the leader node that manages /sync key
        :param sync_standby: collection of currently known synchronous standby node names
        :param quorum: if the node from sync_standby list is doing a leader race it should
                       see at least quorum other nodes from the sync_standby + leader list
        :param version: last known `resource_version` for conditional update of the object
        :returns: the new :class:`SyncState` object or None
        """
        sync_state = self.sync_state(leader, sync_standby, quorum)
        sync_state['quorum'] = str(sync_state['quorum']) if sync_state['quorum'] is not None else None
        ret = self.patch_or_create(self.sync_path, sync_state, version, False)
        if not isinstance(ret, bool):
            return SyncState.from_node(ret.metadata.resource_version, sync_state)
Prepare and write annotations to $SCOPE-sync Endpoint or ConfigMap.

        :param leader: name of the leader node that manages /sync key
        :param sync_standby: collection of currently known synchronous standby node names
        :param quorum: if the node from sync_standby list is doing a leader race it should
                       see at least quorum other nodes from the sync_standby + leader list
        :param version: last known `resource_version` for conditional update of the object
        :returns: the new :class:`SyncState` object or None
        
patroni/dcs/kubernetes.py