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

Code before:
        data_nodes_dict = self.__get_additional_data_nodes(raise_not_existing)
        for _, task in self.__get_tasks(raise_not_existing).items():
            data_nodes_dict.update(task.data_nodes)
        return data_nodes_dict

    def __get_additional_data_nodes(self, raise_not_existing: bool=True) -> Dict[str, DataNode]:
        from ..data._data_manager_factory import _DataManagerFactory

        additional_data_nodes = {}
        non_existing_dns: List = []
        data_manager = _DataManagerFactory._build_manager()

        for dn_or_id in self._additional_data_nodes:
            dn = data_manager._get(dn_or_id, dn_or_id)

            if not isinstance(dn, DataNode):
                if raise_not_existing:
                    raise NonExistingDataNode(dn_or_id)
                non_existing_dns.append(dn_or_id)
                continue
            additional_data_nodes[dn.config_id] = dn
        for dn_id in non_existing_dns:
            self._additional_data_nodes.discard(dn_id)  # type: ignore[arg-type]
        return additional_data_nodes

    def __get_tasks(self, raise_not_existing: bool=True) -> Dict[str, Task]:
        from ..task._task_manager_factory import _TaskManagerFactory

        _tasks = {}
        task_manager = _TaskManagerFactory._build_manager()
        non_existing_tasks: List = []
        for task_or_id in self._tasks:
            t = task_manager._get(task_or_id, task_or_id)

            if not isinstance(t, Task):
                if raise_not_existing:
                    raise NonExistingTask(task_or_id)
                non_existing_tasks.append(task_or_id)
                continue
            _tasks[t.config_id] = t
        for t_id in non_existing_tasks:
            self._tasks.discard(t_id)  # type: ignore[arg-type]
        return _tasks


    @staticmethod
    def __check_sequence_tasks_exist_in_scenario_tasks(
        sequence_name: str, sequence_task_ids: Set[TaskId], scenario_id: ScenarioId, scenario_task_ids: Set[TaskId]
    ):
        non_existing_sequence_task_ids_in_scenario = set()
        for sequence_task_id in sequence_task_ids:

Review comment (suggestion):
```suggestion
    def __get_tasks(self, raise_not_existing: bool = True) -> Dict[str, Task]:
```

Code after:
        data_nodes_dict = self.__get_additional_data_nodes(raise_not_existing)
        for _, task in self.__get_tasks(raise_not_existing).items():
            data_nodes_dict.update(task.data_nodes)
        return data_nodes_dict

    def __get_additional_data_nodes(self, raise_not_existing: bool=True) -> Dict[str, DataNode]:
        from ..data._data_manager_factory import _DataManagerFactory

        additional_data_nodes = {}
        non_existing_dns: List = []
        data_manager = _DataManagerFactory._build_manager()

        for dn_or_id in self._additional_data_nodes:
            dn = data_manager._get(dn_or_id, dn_or_id)

            if not isinstance(dn, DataNode):
                if raise_not_existing:
                    raise NonExistingDataNode(dn_or_id)
                non_existing_dns.append(dn_or_id)
                continue
            additional_data_nodes[dn.config_id] = dn
        for dn_id in non_existing_dns:
            self._additional_data_nodes.discard(dn_id)  # type: ignore[arg-type]
        return additional_data_nodes

    def __get_tasks(self, raise_not_existing: bool = True) -> Dict[str, Task]:
        from ..task._task_manager_factory import _TaskManagerFactory

        _tasks = {}
        task_manager = _TaskManagerFactory._build_manager()
        non_existing_tasks: List = []
        for task_or_id in self._tasks:
            t = task_manager._get(task_or_id, task_or_id)

            if not isinstance(t, Task):
                if raise_not_existing:
                    raise NonExistingTask(task_or_id)
                non_existing_tasks.append(task_or_id)
                continue
            _tasks[t.config_id] = t
        for t_id in non_existing_tasks:
            self._tasks.discard(t_id)  # type: ignore[arg-type]
        return _tasks

    @staticmethod
    def __check_sequence_tasks_exist_in_scenario_tasks(
        sequence_name: str, sequence_task_ids: Set[TaskId], scenario_id: ScenarioId, scenario_task_ids: Set[TaskId]
    ):
        non_existing_sequence_task_ids_in_scenario = set()
        for sequence_task_id in sequence_task_ids:
            if sequence_task_id not in scenario_task_ids: