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

Code before:
        ModelNotFound: No entity corresponds to the specified *entity_id*.
    """
    if _is_job(entity_id):
        job_manager = _JobManagerFactory._build_manager()
        return job_manager._delete(job_manager._get(JobId(entity_id)))
    if _is_cycle(entity_id):
        return _CycleManagerFactory._build_manager()._hard_delete(CycleId(entity_id))
    if _is_scenario(entity_id):
        return _ScenarioManagerFactory._build_manager()._hard_delete(ScenarioId(entity_id))
    if _is_sequence(entity_id):
        return _SequenceManagerFactory._build_manager()._hard_delete(SequenceId(entity_id))
    if _is_task(entity_id):
        return _TaskManagerFactory._build_manager()._hard_delete(TaskId(entity_id))
    if _is_data_node(entity_id):
        return _DataManagerFactory._build_manager()._delete(DataNodeId(entity_id))
    if _is_submission(entity_id):
        return _SubmissionManagerFactory._build_manager()._hard_delete(SubmissionId(entity_id))
    raise ModelNotFound("NOT_DETERMINED", entity_id)


def get_scenarios(
    cycle: Optional[Cycle] = None,
    tag: Optional[str] = None,
    is_sorted: Optional[bool] = False,
    descending: Optional[bool] = False,
    sort_key: Optional[Literal["name", "id", "config_id", "creation_date", "tags"]] = "name",
) -> List[Scenario]:
    """Retrieve a list of existing scenarios filtered by cycle or tag.

    This function allows you to retrieve a list of scenarios based on optional
    filtering criteria. If both a _cycle_ and a _tag_ are provided, the returned
    list contains scenarios that belong to the specified _cycle_ **and** also
    have the specified _tag_.

    Parameters:
         cycle (Optional[Cycle^]): The optional `Cycle^` to filter scenarios by.
         tag (Optional[str]): The optional tag to filter scenarios by.
         is_sorted (Optional[bool]): The option to sort scenarios. The default sorting key is name.
         descending (Optional[bool]): The option to sort scenarios on the sorting key in descending order.
         sort_key (Optional[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 of scenarios filtered by cycle or tag and optionally sorted by name, id, creation_date or tags.
            If no filtering criterion is provided, this method returns all existing scenarios.
            If is_sorted is set to true, the scenarios are sorted by sort_key. The scenarios
            are sorted by name if an incorrect or no sort_key is provided.
    """
    scenario_manager = _ScenarioManagerFactory._build_manager()
    if not cycle and not tag:

Review comment (suggestion):
```suggestion
    is_sorted: bool = False,
    descending: bool = False,
    sort_key: Literal["name", "id", "config_id", "creation_date", "tags"] = "name",
```
`is_sorted`, `descending`, and `sort_key` don't accept `None` as a possible value, so they should not have the `Optional` type.

Code after:
            The identifier of the entity to delete.

    Raises:
        ModelNotFound: No entity corresponds to the specified *entity_id*.
    """
    if _is_job(entity_id):
        job_manager = _JobManagerFactory._build_manager()
        return job_manager._delete(job_manager._get(JobId(entity_id)))
    if _is_cycle(entity_id):
        return _CycleManagerFactory._build_manager()._hard_delete(CycleId(entity_id))
    if _is_scenario(entity_id):
        return _ScenarioManagerFactory._build_manager()._hard_delete(ScenarioId(entity_id))
    if _is_sequence(entity_id):
        return _SequenceManagerFactory._build_manager()._hard_delete(SequenceId(entity_id))
    if _is_task(entity_id):
        return _TaskManagerFactory._build_manager()._hard_delete(TaskId(entity_id))
    if _is_data_node(entity_id):
        return _DataManagerFactory._build_manager()._delete(DataNodeId(entity_id))
    if _is_submission(entity_id):
        return _SubmissionManagerFactory._build_manager()._hard_delete(SubmissionId(entity_id))
    raise ModelNotFound("NOT_DETERMINED", entity_id)


def get_scenarios(
    cycle: Optional[Cycle] = None,
    tag: Optional[str] = None,
    is_sorted: bool = False,
    descending: bool = False,
    sort_key: Literal["name", "id", "config_id", "creation_date", "tags"] = "name",
) -> List[Scenario]:
    """Retrieve a list of existing scenarios filtered by cycle or tag.

    This function allows you to retrieve a list of scenarios based on optional
    filtering criteria. If both a _cycle_ and a _tag_ are provided, the returned
    list contains scenarios that belong to the specified _cycle_ **and** also
    have the specified _tag_.

    Parameters:
         cycle (Optional[Cycle^]): The optional `Cycle^` to filter scenarios by.
         tag (Optional[str]): The optional tag to filter scenarios by.
         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 of scenarios filtered by cycle or tag and optionally sorted by name, id, creation_date or tags.
            If no filtering criterion is provided, this method returns all existing scenarios.
            If is_sorted is set to true, the scenarios are sorted by sort_key. The scenarios
            are sorted by name if an incorrect or no sort_key is provided.