Repository: Avaiga/taipy
File: taipy/core/taipy.py (Python)

Code before:
def get_primary(cycle: Cycle) -> Optional[Scenario]:
    """Retrieve the primary scenario associated with a cycle.

    Parameters:
        cycle (Cycle^): The cycle for which to retrieve the primary scenario.

    Returns:
        The primary scenario of the given _cycle_. If the cycle has no
            primary scenario, this method returns None.
    """
    return _ScenarioManagerFactory._build_manager()._get_primary(cycle)


def get_primary_scenarios(
    is_sorted: bool = False,
    descending: bool = False,
    sort_key: Literal["name", "id", "config_id", "creation_date", "tags"] = "name",
) -> List[Scenario]:
    """Retrieve a list of all primary scenarios.

    Parameters:
         is_sorted (bool): The option to sort scenarios. The default sorting key is name.
         descending (bool): The option to sort scenarios on the sorting key in descending order.
         sort_key (Literal["name", "id", "creation_date", "tags"]): The optiononal sort_key to decide upon
             what key scenarios are sorted. The sorting is in increasing order for dates, in alphabetical order 
             for name and id, in lexographical order for tags.

    Returns:
        The list containing all primary scenarios, optionally sorted by name, id, creation_date or tags.
            The sorting is in increasing order for dates, in alphabetical order for name and 
            id, and in lexicographical order for tags. If sorted is set to true, but if an
            incorrect or no sort_key is provided, the scenarios are sorted by name.
    """
    scenario_manager = _ScenarioManagerFactory._build_manager()
    scenarios = scenario_manager._get_primary_scenarios()
    if is_sorted:
        scenario_manager._sort_scenarios(scenarios, descending, sort_key)
    return scenarios



def is_promotable(scenario: Union[Scenario, ScenarioId]) -> bool:
    """Determine if a scenario can be promoted to become a primary scenario.

    This function checks whether the given scenario is eligible to be promoted
    as a primary scenario.

    Parameters:
        scenario (Union[Scenario, ScenarioId]): The scenario to be evaluated for promotability.

    Returns:

Review comment (suggestion):
W291 Trailing whitespace
```suggestion
         sort_key (Literal["name", "id", "creation_date", "tags"]): The optiononal sort_key to
             decide upon what key scenarios are sorted. The sorting is in increasing order for
             dates, in alphabetical order for name and id, in lexographical order for tags.
```

Code after:
    return scenarios


def get_primary(cycle: Cycle) -> Optional[Scenario]:
    """Retrieve the primary scenario associated with a cycle.

    Parameters:
        cycle (Cycle^): The cycle for which to retrieve the primary scenario.

    Returns:
        The primary scenario of the given _cycle_. If the cycle has no
            primary scenario, this method returns None.
    """
    return _ScenarioManagerFactory._build_manager()._get_primary(cycle)


def get_primary_scenarios(
    is_sorted: bool = False,
    descending: bool = False,
    sort_key: Literal["name", "id", "config_id", "creation_date", "tags"] = "name",
) -> List[Scenario]:
    """Retrieve a list of all primary scenarios.

    Parameters:
         is_sorted (bool): The option to sort scenarios. The default sorting key is name.
         descending (bool): The option to sort scenarios on the sorting key in descending order.
         sort_key (Literal["name", "id", "creation_date", "tags"]): The optiononal sort_key to
             decide upon what key scenarios are sorted. The sorting is in increasing order for
             dates, in alphabetical order for name and id, in lexographical order for tags.

    Returns:
        The list containing all primary scenarios, optionally sorted by name, id, creation_date or tags.
            The sorting is in increasing order for dates, in alphabetical order for name and
            id, and in lexicographical order for tags. If sorted is set to true, but if an
            incorrect or no sort_key is provided, the scenarios are sorted by name.
    """
    scenario_manager = _ScenarioManagerFactory._build_manager()
    scenarios = scenario_manager._get_primary_scenarios()
    if is_sorted:
        scenario_manager._sort_scenarios(scenarios, descending, sort_key)
    return scenarios



def is_promotable(scenario: Union[Scenario, ScenarioId]) -> bool:
    """Determine if a scenario can be promoted to become a primary scenario.

    This function checks whether the given scenario is eligible to be promoted
    as a primary scenario.

    Parameters: