fpl/models/user.py
async def _create_new_lineup(self, players_in, players_out, lineup):
        """Helper for creating the new lineup of players.

        :param players_in: List of IDs of players who will be substituted in.
        :type players_in: list
        :param players_out: List of IDs of players who will be substituted out.
        :type players_out: list
        :param lineup: List containing the user's current lineup.
        :type lineup: list
        :return: Returns the new lineup.
        :rtype: list
        """

        players = await fetch(self._session, API_URLS["static"])
        players = players["elements"]
        _set_element_type(lineup, players)

        subs_in = _ids_to_lineup(players_in, lineup)
        subs_out = _ids_to_lineup(players_out, lineup)

        for sub_out, sub_in in zip(subs_out, subs_in):
            # Get indices of sub out and sub in, then swap their position in
            # the lineup
            out_i, in_i = lineup.index(sub_out), lineup.index(sub_in)
            lineup[out_i], lineup[in_i] = lineup[in_i], lineup[out_i]

            # Swap position and (vice) captaincy
            lineup[out_i]["position"], lineup[in_i]["position"] = (
                lineup[in_i]["position"], lineup[out_i]["position"])
            lineup[out_i][is_c], lineup[in_i][is_c] = (
                lineup[in_i][is_c], lineup[out_i][is_c])
            lineup[out_i][is_vc], lineup[in_i][is_vc] = (
                lineup[in_i][is_vc], lineup[out_i][is_vc])

            starters, subs = lineup[:11], lineup[11:]
            new_starters = sorted(starters, key=lambda x: (
                x["element_type"] - 1) * 100 + x["position"])
            lineup = new_starters + subs

            for position, player in enumerate(lineup):
                player["position"] = position + 1

        new_lineup = [{
            "element": player["element"],
            "position": player["position"],
            "is_captain": player[is_c],
            "is_vice_captain": player[is_vc]
        } for player in lineup]

        return new_lineup
Helper for creating the new lineup of players.

        :param players_in: List of IDs of players who will be substituted in.
        :type players_in: list
        :param players_out: List of IDs of players who will be substituted out.
        :type players_out: list
        :param lineup: List containing the user's current lineup.
        :type lineup: list
        :return: Returns the new lineup.
        :rtype: list
        
Helper for creating the new lineup of players.
Helper for creating the new lineup of players .
async def _create_new_lineup(self, players_in, players_out, lineup):
        players = await fetch(self._session, API_URLS["static"])
        players = players["elements"]
        _set_element_type(lineup, players)
        subs_in = _ids_to_lineup(players_in, lineup)
        subs_out = _ids_to_lineup(players_out, lineup)
        for sub_out, sub_in in zip(subs_out, subs_in):
            out_i, in_i = lineup.index(sub_out), lineup.index(sub_in)
            lineup[out_i], lineup[in_i] = lineup[in_i], lineup[out_i]
            lineup[out_i]["position"], lineup[in_i]["position"] = (
                lineup[in_i]["position"], lineup[out_i]["position"])
            lineup[out_i][is_c], lineup[in_i][is_c] = (
                lineup[in_i][is_c], lineup[out_i][is_c])
            lineup[out_i][is_vc], lineup[in_i][is_vc] = (
                lineup[in_i][is_vc], lineup[out_i][is_vc])
            starters, subs = lineup[:11], lineup[11:]
            new_starters = sorted(starters, key=lambda x: (
                x["element_type"] - 1) * 100 + x["position"])
            lineup = new_starters + subs
            for position, player in enumerate(lineup):
                player["position"] = position + 1
        new_lineup = [{
            "element": player["element"],
            "position": player["position"],
            "is_captain": player[is_c],
            "is_vice_captain": player[is_vc]
        } for player in lineup]
        return new_lineup
async def _create_new_lineup ( self , players_in , players_out , lineup ) : players = await fetch ( self . _session , API_URLS [ "static" ] ) players = players [ "elements" ] _set_element_type ( lineup , players ) subs_in = _ids_to_lineup ( players_in , lineup ) subs_out = _ids_to_lineup ( players_out , lineup ) for sub_out , sub_in in zip ( subs_out , subs_in ) : out_i , in_i = lineup . index ( sub_out ) , lineup . index ( sub_in ) lineup [ out_i ] , lineup [ in_i ] = lineup [ in_i ] , lineup [ out_i ] lineup [ out_i ] [ "position" ] , lineup [ in_i ] [ "position" ] = ( lineup [ in_i ] [ "position" ] , lineup [ out_i ] [ "position" ] ) lineup [ out_i ] [ is_c ] , lineup [ in_i ] [ is_c ] = ( lineup [ in_i ] [ is_c ] , lineup [ out_i ] [ is_c ] ) lineup [ out_i ] [ is_vc ] , lineup [ in_i ] [ is_vc ] = ( lineup [ in_i ] [ is_vc ] , lineup [ out_i ] [ is_vc ] ) starters , subs = lineup [ : 11 ] , lineup [ 11 : ] new_starters = sorted ( starters , key = lambda x : ( x [ "element_type" ] - 1 ) * 100 + x [ "position" ] ) lineup = new_starters + subs for position , player in enumerate ( lineup ) : player [ "position" ] = position + 1 new_lineup = [ { "element" : player [ "element" ] , "position" : player [ "position" ] , "is_captain" : player [ is_c ] , "is_vice_captain" : player [ is_vc ] } for player in lineup ] return new_lineup
Helper for creating the new lineup of players.
Helper for creating the new lineup of players .
"""Helper for creating the new lineup of players.

        :param players_in: List of IDs of players who will be substituted in.
        :type players_in: list
        :param players_out: List of IDs of players who will be substituted out.
        :type players_out: list
        :param lineup: List containing the user's current lineup.
        :type lineup: list
        :return: Returns the new lineup.
        :rtype: list
        """ # Get indices of sub out and sub in, then swap their position in # the lineup # Swap position and (vice) captaincy
Returns the new lineup.
Returns the new lineup .
list
self
players_in
List of IDs of players who will be substituted in.
List of IDs of players who will be substituted in .
players_out
List of IDs of players who will be substituted out.
List of IDs of players who will be substituted out .
lineup
List containing the user's current lineup.
List containing the user ' s current lineup .