Repository: redis/redis-py
File: redis/cluster.py (Python)

Code before:
        """
        Get the node that holds the key's slot.
        If replica set to True but the slot doesn't have any replicas, None is
        returned.
        """
        slot = self.keyslot(key)
        slot_cache = self.nodes_manager.slots_cache.get(slot)
        if slot_cache is None or len(slot_cache) == 0:
            raise SlotNotCoveredError(f'Slot "{slot}" is not covered by the cluster.')
        if replica and len(self.nodes_manager.slots_cache[slot]) < 2:
            return None
        elif replica:
            node_idx = 1
        else:
            # primary
            node_idx = 0

        return slot_cache[node_idx]

    def get_default_node(self):
        """
        Get the cluster's default node
        """
        return self.nodes_manager.default_node

    def get_node_from_slot(self, command: str, *args):
        """
        Returns a list of nodes that hold the specified keys' slots.
        """
        # get the node that holds the key's slot
        slot = self.determine_slot(*args)
        node = self.nodes_manager.get_node_from_slot(
            slot,
            self.read_from_replicas and command in READ_COMMANDS,
            self.load_balancing_strategy if command in READ_COMMANDS else None,
        )
        return [node]

    def _split_multi_shard_command(self, *args, **kwargs) -> list[dict]:
        """
        Splits the command with Multi-Shard policy, to the multiple commands
        """
        keys = self._get_command_keys(*args)
        commands = []

        for key in keys:
            commands.append({
                'args': (args[0], key),
                'kwargs': kwargs,
            })


Review comment (suggestion):
Since a list is returned here, `get_nodes_from_slot` would be a better name for the method

Code after:
        """
        Get the node that holds the key's slot.
        If replica set to True but the slot doesn't have any replicas, None is
        returned.
        """
        slot = self.keyslot(key)
        slot_cache = self.nodes_manager.slots_cache.get(slot)
        if slot_cache is None or len(slot_cache) == 0:
            raise SlotNotCoveredError(f'Slot "{slot}" is not covered by the cluster.')
        if replica and len(self.nodes_manager.slots_cache[slot]) < 2:
            return None
        elif replica:
            node_idx = 1
        else:
            # primary
            node_idx = 0

        return slot_cache[node_idx]

    def get_default_node(self):
        """
        Get the cluster's default node
        """
        return self.nodes_manager.default_node

    def get_nodes_from_slot(self, command: str, *args):
        """
        Returns a list of nodes that hold the specified keys' slots.
        """
        # get the node that holds the key's slot
        slot = self.determine_slot(*args)
        node = self.nodes_manager.get_node_from_slot(
            slot,
            self.read_from_replicas and command in READ_COMMANDS,
            self.load_balancing_strategy if command in READ_COMMANDS else None,
        )
        return [node]

    def _split_multi_shard_command(self, *args, **kwargs) -> list[dict]:
        """
        Splits the command with Multi-Shard policy, to the multiple commands
        """
        keys = self._get_command_keys(*args)
        commands = []

        for key in keys:
            commands.append({
                'args': (args[0], key),
                'kwargs': kwargs,
            })