ソースを参照

Removing useless type annotation (#1193)

Add None return type to init methods
Jean-Robin 1 年間 前
コミット
4278574124
41 ファイル変更96 行追加87 行削除
  1. 6 6
      taipy/config/_config.py
  2. 2 2
      taipy/config/_config_comparator/_config_comparator.py
  3. 4 4
      taipy/config/checker/issue_collector.py
  4. 4 4
      taipy/config/config.pyi
  5. 1 1
      taipy/core/_core.py
  6. 13 8
      taipy/core/_entity/_entity_ids.py
  7. 1 1
      taipy/core/_entity/_reload.py
  8. 1 1
      taipy/core/_version/_version_fs_repository.py
  9. 1 1
      taipy/core/_version/_version_sql_repository.py
  10. 12 12
      taipy/core/config/task_config.py
  11. 1 1
      taipy/core/cycle/_cycle_fs_repository.py
  12. 1 1
      taipy/core/cycle/_cycle_sql_repository.py
  13. 1 1
      taipy/core/data/_data_fs_repository.py
  14. 1 1
      taipy/core/data/_data_sql_repository.py
  15. 2 2
      taipy/core/data/data_node.py
  16. 1 1
      taipy/core/job/_job_fs_repository.py
  17. 1 1
      taipy/core/job/_job_sql_repository.py
  18. 5 5
      taipy/core/notification/core_event_consumer.py
  19. 1 1
      taipy/core/scenario/_scenario_fs_repository.py
  20. 1 1
      taipy/core/scenario/_scenario_sql_repository.py
  21. 1 1
      taipy/core/submission/_submission_fs_repository.py
  22. 1 1
      taipy/core/submission/_submission_sql_repository.py
  23. 2 2
      taipy/core/submission/submission.py
  24. 1 1
      taipy/core/task/_task_fs_repository.py
  25. 3 2
      taipy/core/task/_task_manager.py
  26. 1 1
      taipy/core/task/_task_sql_repository.py
  27. 2 2
      taipy/core/task/task.py
  28. 1 1
      taipy/gui/_page.py
  29. 1 1
      taipy/gui/_renderers/json.py
  30. 1 1
      taipy/gui/builder/_api_generator.py
  31. 1 1
      taipy/gui/builder/_context_manager.py
  32. 2 2
      taipy/gui/builder/_element.py
  33. 1 1
      taipy/gui/config.py
  34. 1 1
      taipy/gui/utils/_adapter.py
  35. 1 1
      taipy/gui/utils/_runtime_manager.py
  36. 3 3
      taipy/rest/api/exceptions/exceptions.py
  37. 1 1
      taipy/rest/app.py
  38. 4 2
      taipy/rest/rest.py
  39. 6 5
      tests/core/notification/test_events_published.py
  40. 1 1
      tests/gui/e2e/page_scopes/assets2_class_scopes/page1.py
  41. 1 1
      tests/gui/e2e/page_scopes/assets2_class_scopes/page2.py

+ 6 - 6
taipy/config/_config.py

@@ -20,12 +20,12 @@ from .unique_section import UniqueSection
 class _Config:
 class _Config:
     DEFAULT_KEY = "default"
     DEFAULT_KEY = "default"
 
 
-    def __init__(self):
+    def __init__(self) -> None:
         self._sections: Dict[str, Dict[str, Section]] = {}
         self._sections: Dict[str, Dict[str, Section]] = {}
         self._unique_sections: Dict[str, UniqueSection] = {}
         self._unique_sections: Dict[str, UniqueSection] = {}
         self._global_config: GlobalAppConfig = GlobalAppConfig()
         self._global_config: GlobalAppConfig = GlobalAppConfig()
 
 
-    def _clean(self):
+    def _clean(self) -> None:
         self._global_config._clean()
         self._global_config._clean()
         for unique_section in self._unique_sections.values():
         for unique_section in self._unique_sections.values():
             unique_section._clean()
             unique_section._clean()
@@ -39,7 +39,7 @@ class _Config:
         config._global_config = GlobalAppConfig.default_config()
         config._global_config = GlobalAppConfig.default_config()
         return config
         return config
 
 
-    def _update(self, other_config):
+    def _update(self, other_config) -> None:
         self._global_config._update(other_config._global_config._to_dict())
         self._global_config._update(other_config._global_config._to_dict())
         if other_config._unique_sections:
         if other_config._unique_sections:
             for section_name, other_section in other_config._unique_sections.items():
             for section_name, other_section in other_config._unique_sections.items():
@@ -55,12 +55,12 @@ class _Config:
                     self._sections[section_name] = {}
                     self._sections[section_name] = {}
                     self.__add_sections(self._sections[section_name], other_non_unique_sections)
                     self.__add_sections(self._sections[section_name], other_non_unique_sections)
 
 
-    def __add_sections(self, entity_config, other_entity_configs):
+    def __add_sections(self, entity_config, other_entity_configs) -> None:
         for cfg_id, sub_config in other_entity_configs.items():
         for cfg_id, sub_config in other_entity_configs.items():
             entity_config[cfg_id] = copy(sub_config)
             entity_config[cfg_id] = copy(sub_config)
             self.__point_nested_section_to_self(sub_config)
             self.__point_nested_section_to_self(sub_config)
 
 
-    def __update_sections(self, entity_config, other_entity_configs):
+    def __update_sections(self, entity_config, other_entity_configs) -> None:
         if self.DEFAULT_KEY in other_entity_configs:
         if self.DEFAULT_KEY in other_entity_configs:
             if self.DEFAULT_KEY in entity_config:
             if self.DEFAULT_KEY in entity_config:
                 entity_config[self.DEFAULT_KEY]._update(other_entity_configs[self.DEFAULT_KEY]._to_dict())
                 entity_config[self.DEFAULT_KEY]._update(other_entity_configs[self.DEFAULT_KEY]._to_dict())
@@ -73,7 +73,7 @@ class _Config:
                 entity_config[cfg_id]._update(sub_config._to_dict(), entity_config.get(self.DEFAULT_KEY))
                 entity_config[cfg_id]._update(sub_config._to_dict(), entity_config.get(self.DEFAULT_KEY))
             self.__point_nested_section_to_self(sub_config)
             self.__point_nested_section_to_self(sub_config)
 
 
-    def __point_nested_section_to_self(self, section):
+    def __point_nested_section_to_self(self, section) -> None:
         """Loop through attributes of a Section to find if any attribute has a list of Section as value.
         """Loop through attributes of a Section to find if any attribute has a list of Section as value.
         If there is, update each nested Section by the corresponding instance in self.
         If there is, update each nested Section by the corresponding instance in self.
 
 

+ 2 - 2
taipy/config/_config_comparator/_config_comparator.py

@@ -22,11 +22,11 @@ from ._comparator_result import _ComparatorResult
 
 
 
 
 class _ConfigComparator:
 class _ConfigComparator:
-    def __init__(self):
+    def __init__(self) -> None:
         self._unconflicted_sections: Set[str] = set()
         self._unconflicted_sections: Set[str] = set()
         self.__logger = _TaipyLogger._get_logger()
         self.__logger = _TaipyLogger._get_logger()
 
 
-    def _add_unconflicted_section(self, section_name: Union[str, Set[str]]):
+    def _add_unconflicted_section(self, section_name: Union[str, Set[str]]) -> None:
         if isinstance(section_name, str):
         if isinstance(section_name, str):
             section_name = {section_name}
             section_name = {section_name}
 
 

+ 4 - 4
taipy/config/checker/issue_collector.py

@@ -29,7 +29,7 @@ class IssueCollector:
     _WARNING_LEVEL = "WARNING"
     _WARNING_LEVEL = "WARNING"
     _INFO_LEVEL = "INFO"
     _INFO_LEVEL = "INFO"
 
 
-    def __init__(self):
+    def __init__(self) -> None:
         self._errors: List[Issue] = []
         self._errors: List[Issue] = []
         self._warnings: List[Issue] = []
         self._warnings: List[Issue] = []
         self._infos: List[Issue] = []
         self._infos: List[Issue] = []
@@ -50,11 +50,11 @@ class IssueCollector:
     def errors(self) -> List[Issue]:
     def errors(self) -> List[Issue]:
         return self._errors
         return self._errors
 
 
-    def _add_error(self, field: str, value: Any, message: str, checker_name: str):
+    def _add_error(self, field: str, value: Any, message: str, checker_name: str) -> None:
         self._errors.append(Issue(self._ERROR_LEVEL, field, value, message, checker_name))
         self._errors.append(Issue(self._ERROR_LEVEL, field, value, message, checker_name))
 
 
-    def _add_warning(self, field: str, value: Any, message: str, checker_name: str):
+    def _add_warning(self, field: str, value: Any, message: str, checker_name: str) -> None:
         self._warnings.append(Issue(self._WARNING_LEVEL, field, value, message, checker_name))
         self._warnings.append(Issue(self._WARNING_LEVEL, field, value, message, checker_name))
 
 
-    def _add_info(self, field: str, value: Any, message: str, checker_name: str):
+    def _add_info(self, field: str, value: Any, message: str, checker_name: str) -> None:
         self._infos.append(Issue(self._INFO_LEVEL, field, value, message, checker_name))
         self._infos.append(Issue(self._INFO_LEVEL, field, value, message, checker_name))

+ 4 - 4
taipy/config/config.pyi

@@ -787,10 +787,10 @@ class Config:
     @staticmethod
     @staticmethod
     def configure_task(
     def configure_task(
         id: str,
         id: str,
-        function,
+        function: Optional[Callable],
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
         **properties,
     ) -> "TaskConfig":
     ) -> "TaskConfig":
         """Configure a new task configuration.
         """Configure a new task configuration.
@@ -815,10 +815,10 @@ class Config:
 
 
     @staticmethod
     @staticmethod
     def set_default_task_configuration(
     def set_default_task_configuration(
-        function,
+        function: Optional[Callable],
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
         **properties,
     ) -> "TaskConfig":
     ) -> "TaskConfig":
         """Set the default values for task configurations.
         """Set the default values for task configurations.

+ 1 - 1
taipy/core/_core.py

@@ -40,7 +40,7 @@ class Core:
     _orchestrator: Optional[_Orchestrator] = None
     _orchestrator: Optional[_Orchestrator] = None
     _dispatcher: Optional[_JobDispatcher] = None
     _dispatcher: Optional[_JobDispatcher] = None
 
 
-    def __init__(self):
+    def __init__(self) -> None:
         """
         """
         Initialize a Core service.
         Initialize a Core service.
         """
         """

+ 13 - 8
taipy/core/_entity/_entity_ids.py

@@ -11,16 +11,21 @@
 
 
 from __future__ import annotations
 from __future__ import annotations
 
 
+from typing import TYPE_CHECKING, Set
+
+if TYPE_CHECKING:
+    from taipy import CycleId, DataNodeId, JobId, ScenarioId, SequenceId, SubmissionId, TaskId
+
 
 
 class _EntityIds:
 class _EntityIds:
-    def __init__(self):
-        self.data_node_ids = set()
-        self.task_ids = set()
-        self.scenario_ids = set()
-        self.sequence_ids = set()
-        self.job_ids = set()
-        self.cycle_ids = set()
-        self.submission_ids = set()
+    def __init__(self) -> None:
+        self.data_node_ids: Set[DataNodeId] = set()
+        self.task_ids: Set[TaskId] = set()
+        self.scenario_ids: Set[ScenarioId] = set()
+        self.sequence_ids: Set[SequenceId] = set()
+        self.job_ids: Set[JobId] = set()
+        self.cycle_ids: Set[CycleId] = set()
+        self.submission_ids: Set[SubmissionId] = set()
 
 
     def __add__(self, other: _EntityIds):
     def __add__(self, other: _EntityIds):
         self.data_node_ids.update(other.data_node_ids)
         self.data_node_ids.update(other.data_node_ids)

+ 1 - 1
taipy/core/_entity/_reload.py

@@ -48,7 +48,7 @@ class _Reloader:
         self._no_reload_context = False
         self._no_reload_context = False
 
 
 
 
-def _self_reload(manager):
+def _self_reload(manager: str):
     def __reload(fct):
     def __reload(fct):
         @functools.wraps(fct)
         @functools.wraps(fct)
         def _do_reload(self, *args, **kwargs):
         def _do_reload(self, *args, **kwargs):

+ 1 - 1
taipy/core/_version/_version_fs_repository.py

@@ -22,7 +22,7 @@ from ._version_repository_interface import _VersionRepositoryInterface
 
 
 
 
 class _VersionFSRepository(_FileSystemRepository, _VersionRepositoryInterface):
 class _VersionFSRepository(_FileSystemRepository, _VersionRepositoryInterface):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_VersionModel, converter=_VersionConverter, dir_name="version")
         super().__init__(model_type=_VersionModel, converter=_VersionConverter, dir_name="version")
 
 
     @property
     @property

+ 1 - 1
taipy/core/_version/_version_sql_repository.py

@@ -19,7 +19,7 @@ from ._version_repository_interface import _VersionRepositoryInterface
 
 
 
 
 class _VersionSQLRepository(_SQLRepository, _VersionRepositoryInterface):
 class _VersionSQLRepository(_SQLRepository, _VersionRepositoryInterface):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_VersionModel, converter=_VersionConverter)
         super().__init__(model_type=_VersionModel, converter=_VersionConverter)
 
 
     def _set_latest_version(self, version_number):
     def _set_latest_version(self, version_number):

+ 12 - 12
taipy/core/config/task_config.py

@@ -10,7 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 from copy import copy
 from copy import copy
-from typing import Any, Dict, List, Optional, Union, cast
+from typing import Any, Callable, Dict, List, Optional, Union, cast
 
 
 from taipy.config._config import _Config
 from taipy.config._config import _Config
 from taipy.config.common._template_handler import _TemplateHandler as _tpl
 from taipy.config.common._template_handler import _TemplateHandler as _tpl
@@ -53,12 +53,12 @@ class TaskConfig(Section):
     def __init__(
     def __init__(
         self,
         self,
         id: str,
         id: str,
-        function,
+        function: Optional[Callable],
         inputs: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         inputs: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         outputs: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         outputs: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
         **properties,
-    ):
+    ) -> None:
         if inputs:
         if inputs:
             self._inputs = [inputs] if isinstance(inputs, DataNodeConfig) else copy(inputs)
             self._inputs = [inputs] if isinstance(inputs, DataNodeConfig) else copy(inputs)
         else:
         else:
@@ -71,8 +71,8 @@ class TaskConfig(Section):
                 skippable = True
                 skippable = True
         else:
         else:
             self._outputs = []
             self._outputs = []
-        self._skippable = skippable
-        self.function = function
+        self._skippable: bool = skippable
+        self.function: Optional[Callable] = function
         super().__init__(id, **properties)
         super().__init__(id, **properties)
 
 
     def __copy__(self):
     def __copy__(self):
@@ -100,14 +100,14 @@ class TaskConfig(Section):
         return list(self._outputs)
         return list(self._outputs)
 
 
     @property
     @property
-    def skippable(self):
+    def skippable(self) -> bool:
         return _tpl._replace_templates(self._skippable)
         return _tpl._replace_templates(self._skippable)
 
 
     @classmethod
     @classmethod
     def default_config(cls):
     def default_config(cls):
         return TaskConfig(cls._DEFAULT_KEY, None, [], [], False)
         return TaskConfig(cls._DEFAULT_KEY, None, [], [], False)
 
 
-    def _clean(self):
+    def _clean(self) -> None:
         self.function = None
         self.function = None
         self._inputs = []
         self._inputs = []
         self._outputs = []
         self._outputs = []
@@ -158,10 +158,10 @@ class TaskConfig(Section):
     @staticmethod
     @staticmethod
     def _configure(
     def _configure(
         id: str,
         id: str,
-        function,
+        function: Optional[Callable],
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
         **properties,
     ) -> "TaskConfig":
     ) -> "TaskConfig":
         """Configure a new task configuration.
         """Configure a new task configuration.
@@ -189,10 +189,10 @@ class TaskConfig(Section):
 
 
     @staticmethod
     @staticmethod
     def _set_default_configuration(
     def _set_default_configuration(
-        function,
+        function: Optional[Callable],
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
         **properties,
     ) -> "TaskConfig":
     ) -> "TaskConfig":
         """Set the default values for task configurations.
         """Set the default values for task configurations.

+ 1 - 1
taipy/core/cycle/_cycle_fs_repository.py

@@ -14,5 +14,5 @@ from ._cycle_model import _CycleModel
 
 
 
 
 class _CycleFSRepository(_FileSystemRepository):
 class _CycleFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_CycleModel, converter=_CycleConverter, dir_name="cycles")
         super().__init__(model_type=_CycleModel, converter=_CycleConverter, dir_name="cycles")

+ 1 - 1
taipy/core/cycle/_cycle_sql_repository.py

@@ -14,5 +14,5 @@ from ._cycle_model import _CycleModel
 
 
 
 
 class _CycleSQLRepository(_SQLRepository):
 class _CycleSQLRepository(_SQLRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_CycleModel, converter=_CycleConverter)
         super().__init__(model_type=_CycleModel, converter=_CycleConverter)

+ 1 - 1
taipy/core/data/_data_fs_repository.py

@@ -14,5 +14,5 @@ from ._data_model import _DataNodeModel
 
 
 
 
 class _DataFSRepository(_FileSystemRepository):
 class _DataFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_DataNodeModel, converter=_DataNodeConverter, dir_name="data_nodes")
         super().__init__(model_type=_DataNodeModel, converter=_DataNodeConverter, dir_name="data_nodes")

+ 1 - 1
taipy/core/data/_data_sql_repository.py

@@ -14,5 +14,5 @@ from ._data_model import _DataNodeModel
 
 
 
 
 class _DataSQLRepository(_SQLRepository):
 class _DataSQLRepository(_SQLRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_DataNodeModel, converter=_DataNodeConverter)
         super().__init__(model_type=_DataNodeModel, converter=_DataNodeConverter)

+ 2 - 2
taipy/core/data/data_node.py

@@ -82,7 +82,7 @@ class DataNode(_Entity, _Labeled):
     __ID_SEPARATOR = "_"
     __ID_SEPARATOR = "_"
     __logger = _TaipyLogger._get_logger()
     __logger = _TaipyLogger._get_logger()
     _REQUIRED_PROPERTIES: List[str] = []
     _REQUIRED_PROPERTIES: List[str] = []
-    _MANAGER_NAME = "data"
+    _MANAGER_NAME: str = "data"
     __PATH_KEY = "path"
     __PATH_KEY = "path"
     __EDIT_TIMEOUT = 30
     __EDIT_TIMEOUT = 30
 
 
@@ -103,7 +103,7 @@ class DataNode(_Entity, _Labeled):
         editor_id: Optional[str] = None,
         editor_id: Optional[str] = None,
         editor_expiration_date: Optional[datetime] = None,
         editor_expiration_date: Optional[datetime] = None,
         **kwargs,
         **kwargs,
-    ):
+    ) -> None:
         self._config_id = _validate_id(config_id)
         self._config_id = _validate_id(config_id)
         self.id = id or DataNodeId(self.__ID_SEPARATOR.join([self._ID_PREFIX, self.config_id, str(uuid.uuid4())]))
         self.id = id or DataNodeId(self.__ID_SEPARATOR.join([self._ID_PREFIX, self.config_id, str(uuid.uuid4())]))
         self._owner_id = owner_id
         self._owner_id = owner_id

+ 1 - 1
taipy/core/job/_job_fs_repository.py

@@ -14,5 +14,5 @@ from ._job_model import _JobModel
 
 
 
 
 class _JobFSRepository(_FileSystemRepository):
 class _JobFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_JobModel, converter=_JobConverter, dir_name="jobs")
         super().__init__(model_type=_JobModel, converter=_JobConverter, dir_name="jobs")

+ 1 - 1
taipy/core/job/_job_sql_repository.py

@@ -14,5 +14,5 @@ from ._job_model import _JobModel
 
 
 
 
 class _JobSQLRepository(_SQLRepository):
 class _JobSQLRepository(_SQLRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_JobModel, converter=_JobConverter)
         super().__init__(model_type=_JobModel, converter=_JobConverter)

+ 5 - 5
taipy/core/notification/core_event_consumer.py

@@ -46,7 +46,7 @@ class CoreEventConsumerBase(threading.Thread):
 
 
     """
     """
 
 
-    def __init__(self, registration_id: str, queue: SimpleQueue):
+    def __init__(self, registration_id: str, queue: SimpleQueue) -> None:
         """Initialize a CoreEventConsumerBase instance.
         """Initialize a CoreEventConsumerBase instance.
 
 
         Parameters:
         Parameters:
@@ -61,16 +61,16 @@ class CoreEventConsumerBase(threading.Thread):
         self.__STOP_FLAG = False
         self.__STOP_FLAG = False
         self._TIMEOUT = 0.1
         self._TIMEOUT = 0.1
 
 
-    def start(self):
+    def start(self) -> None:
         """Start the event consumer thread."""
         """Start the event consumer thread."""
         self.__STOP_FLAG = False
         self.__STOP_FLAG = False
         threading.Thread.start(self)
         threading.Thread.start(self)
 
 
-    def stop(self):
+    def stop(self) -> None:
         """Stop the event consumer thread."""
         """Stop the event consumer thread."""
         self.__STOP_FLAG = True
         self.__STOP_FLAG = True
 
 
-    def run(self):
+    def run(self) -> None:
         while not self.__STOP_FLAG:
         while not self.__STOP_FLAG:
             try:
             try:
                 event: Event = self.queue.get(block=True, timeout=self._TIMEOUT)
                 event: Event = self.queue.get(block=True, timeout=self._TIMEOUT)
@@ -79,6 +79,6 @@ class CoreEventConsumerBase(threading.Thread):
                 pass
                 pass
 
 
     @abc.abstractmethod
     @abc.abstractmethod
-    def process_event(self, event: Event):
+    def process_event(self, event: Event) -> None:
         """This method should be overridden in subclasses to define how events are processed."""
         """This method should be overridden in subclasses to define how events are processed."""
         raise NotImplementedError
         raise NotImplementedError

+ 1 - 1
taipy/core/scenario/_scenario_fs_repository.py

@@ -14,5 +14,5 @@ from ._scenario_model import _ScenarioModel
 
 
 
 
 class _ScenarioFSRepository(_FileSystemRepository):
 class _ScenarioFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_ScenarioModel, converter=_ScenarioConverter, dir_name="scenarios")
         super().__init__(model_type=_ScenarioModel, converter=_ScenarioConverter, dir_name="scenarios")

+ 1 - 1
taipy/core/scenario/_scenario_sql_repository.py

@@ -14,5 +14,5 @@ from ._scenario_model import _ScenarioModel
 
 
 
 
 class _ScenarioSQLRepository(_SQLRepository):
 class _ScenarioSQLRepository(_SQLRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_ScenarioModel, converter=_ScenarioConverter)
         super().__init__(model_type=_ScenarioModel, converter=_ScenarioConverter)

+ 1 - 1
taipy/core/submission/_submission_fs_repository.py

@@ -14,5 +14,5 @@ from ._submission_model import _SubmissionModel
 
 
 
 
 class _SubmissionFSRepository(_FileSystemRepository):
 class _SubmissionFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_SubmissionModel, converter=_SubmissionConverter, dir_name="submission")
         super().__init__(model_type=_SubmissionModel, converter=_SubmissionConverter, dir_name="submission")

+ 1 - 1
taipy/core/submission/_submission_sql_repository.py

@@ -14,5 +14,5 @@ from ._submission_model import _SubmissionModel
 
 
 
 
 class _SubmissionSQLRepository(_SQLRepository):
 class _SubmissionSQLRepository(_SQLRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_SubmissionModel, converter=_SubmissionConverter)
         super().__init__(model_type=_SubmissionModel, converter=_SubmissionConverter)

+ 2 - 2
taipy/core/submission/submission.py

@@ -52,7 +52,7 @@ class Submission(_Entity, _Labeled):
         entity_id: str,
         entity_id: str,
         entity_type: str,
         entity_type: str,
         entity_config_id: Optional[str] = None,
         entity_config_id: Optional[str] = None,
-        id: Optional[str] = None,
+        id: Optional[SubmissionId] = None,
         jobs: Optional[Union[List[Job], List[JobId]]] = None,
         jobs: Optional[Union[List[Job], List[JobId]]] = None,
         properties: Optional[Dict[str, Any]] = None,
         properties: Optional[Dict[str, Any]] = None,
         creation_date: Optional[datetime] = None,
         creation_date: Optional[datetime] = None,
@@ -80,7 +80,7 @@ class Submission(_Entity, _Labeled):
         self._pending_jobs: Set = set()
         self._pending_jobs: Set = set()
 
 
     @staticmethod
     @staticmethod
-    def __new_id() -> str:
+    def __new_id() -> SubmissionId:
         """Generate a unique Submission identifier."""
         """Generate a unique Submission identifier."""
         return SubmissionId(Submission.__SEPARATOR.join([Submission._ID_PREFIX, str(uuid.uuid4())]))
         return SubmissionId(Submission.__SEPARATOR.join([Submission._ID_PREFIX, str(uuid.uuid4())]))
 
 

+ 1 - 1
taipy/core/task/_task_fs_repository.py

@@ -14,5 +14,5 @@ from ._task_model import _TaskModel
 
 
 
 
 class _TaskFSRepository(_FileSystemRepository):
 class _TaskFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_TaskModel, converter=_TaskConverter, dir_name="tasks")
         super().__init__(model_type=_TaskModel, converter=_TaskConverter, dir_name="tasks")

+ 3 - 2
taipy/core/task/_task_manager.py

@@ -9,7 +9,7 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
-from typing import Callable, List, Optional, Type, Union
+from typing import Callable, List, Optional, Type, Union, cast
 
 
 from taipy.config import Config
 from taipy.config import Config
 from taipy.config.common.scope import Scope
 from taipy.config.common.scope import Scope
@@ -101,10 +101,11 @@ class _TaskManager(_Manager[Task], _VersionMixin):
                     for output_config in [Config.data_nodes[dnc.id] for dnc in task_config.output_configs]
                     for output_config in [Config.data_nodes[dnc.id] for dnc in task_config.output_configs]
                 ]
                 ]
                 skippable = task_config.skippable
                 skippable = task_config.skippable
+
                 task = Task(
                 task = Task(
                     str(task_config.id),
                     str(task_config.id),
                     dict(**task_config._properties),
                     dict(**task_config._properties),
-                    task_config.function,
+                    cast(Callable, task_config.function),
                     inputs,
                     inputs,
                     outputs,
                     outputs,
                     owner_id=owner_id,
                     owner_id=owner_id,

+ 1 - 1
taipy/core/task/_task_sql_repository.py

@@ -14,5 +14,5 @@ from ._task_model import _TaskModel
 
 
 
 
 class _TaskSQLRepository(_SQLRepository):
 class _TaskSQLRepository(_SQLRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_TaskModel, converter=_TaskConverter)
         super().__init__(model_type=_TaskModel, converter=_TaskConverter)

+ 2 - 2
taipy/core/task/task.py

@@ -58,7 +58,7 @@ class Task(_Entity, _Labeled):
         self,
         self,
         config_id: str,
         config_id: str,
         properties: Dict[str, Any],
         properties: Dict[str, Any],
-        function,
+        function: Callable,
         input: Optional[Iterable[DataNode]] = None,
         input: Optional[Iterable[DataNode]] = None,
         output: Optional[Iterable[DataNode]] = None,
         output: Optional[Iterable[DataNode]] = None,
         id: Optional[TaskId] = None,
         id: Optional[TaskId] = None,
@@ -66,7 +66,7 @@ class Task(_Entity, _Labeled):
         parent_ids: Optional[Set[str]] = None,
         parent_ids: Optional[Set[str]] = None,
         version: Optional[str] = None,
         version: Optional[str] = None,
         skippable: bool = False,
         skippable: bool = False,
-    ):
+    ) -> None:
         self._config_id = _validate_id(config_id)
         self._config_id = _validate_id(config_id)
         self.id = id or TaskId(self.__ID_SEPARATOR.join([self._ID_PREFIX, self.config_id, str(uuid.uuid4())]))
         self.id = id or TaskId(self.__ID_SEPARATOR.join([self._ID_PREFIX, self.config_id, str(uuid.uuid4())]))
         self._owner_id = owner_id
         self._owner_id = owner_id

+ 1 - 1
taipy/gui/_page.py

@@ -22,7 +22,7 @@ if t.TYPE_CHECKING:
 
 
 
 
 class _Page(object):
 class _Page(object):
-    def __init__(self):
+    def __init__(self) -> None:
         self._rendered_jsx: t.Optional[str] = None
         self._rendered_jsx: t.Optional[str] = None
         self._renderer: t.Optional[Page] = None
         self._renderer: t.Optional[Page] = None
         self._style: t.Optional[str] = None
         self._style: t.Optional[str] = None

+ 1 - 1
taipy/gui/_renderers/json.py

@@ -54,7 +54,7 @@ class _DefaultJsonAdapter(JsonAdapter):
 
 
 
 
 class _TaipyJsonAdapter(object, metaclass=_Singleton):
 class _TaipyJsonAdapter(object, metaclass=_Singleton):
-    def __init__(self):
+    def __init__(self) -> None:
         self._adapters: t.List[JsonAdapter] = []
         self._adapters: t.List[JsonAdapter] = []
         self.register(_DefaultJsonAdapter())
         self.register(_DefaultJsonAdapter())
 
 

+ 1 - 1
taipy/gui/builder/_api_generator.py

@@ -27,7 +27,7 @@ if t.TYPE_CHECKING:
 
 
 
 
 class _ElementApiGenerator(object, metaclass=_Singleton):
 class _ElementApiGenerator(object, metaclass=_Singleton):
-    def __init__(self):
+    def __init__(self) -> None:
         self.__module: t.Optional[types.ModuleType] = None
         self.__module: t.Optional[types.ModuleType] = None
 
 
     @staticmethod
     @staticmethod

+ 1 - 1
taipy/gui/builder/_context_manager.py

@@ -18,7 +18,7 @@ if t.TYPE_CHECKING:
 
 
 
 
 class _BuilderContextManager(object, metaclass=_Singleton):
 class _BuilderContextManager(object, metaclass=_Singleton):
-    def __init__(self):
+    def __init__(self) -> None:
         self.__blocks: t.List["_Block"] = []
         self.__blocks: t.List["_Block"] = []
 
 
     def push(self, element: "_Block") -> None:
     def push(self, element: "_Block") -> None:

+ 2 - 2
taipy/gui/builder/_element.py

@@ -38,7 +38,7 @@ class _Element(ABC):
             parent.add(obj)
             parent.add(obj)
         return obj
         return obj
 
 
-    def __init__(self, *args, **kwargs):
+    def __init__(self, *args, **kwargs) -> None:
         self._properties: t.Dict[str, t.Any] = {}
         self._properties: t.Dict[str, t.Any] = {}
         if args and self._DEFAULT_PROPERTY != "":
         if args and self._DEFAULT_PROPERTY != "":
             self._properties = {self._DEFAULT_PROPERTY: args[0]}
             self._properties = {self._DEFAULT_PROPERTY: args[0]}
@@ -81,7 +81,7 @@ class _Element(ABC):
 class _Block(_Element):
 class _Block(_Element):
     """NOT DOCUMENTED"""
     """NOT DOCUMENTED"""
 
 
-    def __init__(self, *args, **kwargs):
+    def __init__(self, *args, **kwargs) -> None:
         super().__init__(*args, **kwargs)
         super().__init__(*args, **kwargs)
         self._children: t.List[_Element] = []
         self._children: t.List[_Element] = []
 
 

+ 1 - 1
taipy/gui/config.py

@@ -144,7 +144,7 @@ class _Config(object):
         r"^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$"
         r"^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$"
     )
     )
 
 
-    def __init__(self):
+    def __init__(self) -> None:
         self.pages: t.List[_Page] = []
         self.pages: t.List[_Page] = []
         self.root_page: t.Optional[_Page] = None
         self.root_page: t.Optional[_Page] = None
         self.routes: t.List[str] = []
         self.routes: t.List[str] = []

+ 1 - 1
taipy/gui/utils/_adapter.py

@@ -19,7 +19,7 @@ from . import _MapDict
 
 
 
 
 class _Adapter:
 class _Adapter:
-    def __init__(self):
+    def __init__(self) -> None:
         self.__adapter_for_type: t.Dict[str, t.Callable] = {}
         self.__adapter_for_type: t.Dict[str, t.Callable] = {}
         self.__type_for_variable: t.Dict[str, str] = {}
         self.__type_for_variable: t.Dict[str, str] = {}
         self.__warning_by_type: t.Set[str] = set()
         self.__warning_by_type: t.Set[str] = set()

+ 1 - 1
taipy/gui/utils/_runtime_manager.py

@@ -18,7 +18,7 @@ if t.TYPE_CHECKING:
 
 
 
 
 class _RuntimeManager(object, metaclass=_Singleton):
 class _RuntimeManager(object, metaclass=_Singleton):
-    def __init__(self):
+    def __init__(self) -> None:
         self.__port_gui: t.Dict[int, "Gui"] = {}
         self.__port_gui: t.Dict[int, "Gui"] = {}
 
 
     def add_gui(self, gui: "Gui", port: int):
     def add_gui(self, gui: "Gui", port: int):

+ 3 - 3
taipy/rest/api/exceptions/exceptions.py

@@ -11,15 +11,15 @@
 
 
 
 
 class ConfigIdMissingException(Exception):
 class ConfigIdMissingException(Exception):
-    def __init__(self):
+    def __init__(self) -> None:
         self.message = "Config id is missing."
         self.message = "Config id is missing."
 
 
 
 
 class ScenarioIdMissingException(Exception):
 class ScenarioIdMissingException(Exception):
-    def __init__(self):
+    def __init__(self) -> None:
         self.message = "Scenario id is missing."
         self.message = "Scenario id is missing."
 
 
 
 
 class SequenceNameMissingException(Exception):
 class SequenceNameMissingException(Exception):
-    def __init__(self):
+    def __init__(self) -> None:
         self.message = "Sequence name is missing."
         self.message = "Sequence name is missing."

+ 1 - 1
taipy/rest/app.py

@@ -18,7 +18,7 @@ from .commons.encoder import _CustomEncoder
 from .extensions import apispec
 from .extensions import apispec
 
 
 
 
-def create_app(testing=False, flask_env=None, secret_key=None):
+def create_app(testing=False, flask_env=None, secret_key=None) -> Flask:
     """Application factory, used to create application"""
     """Application factory, used to create application"""
     app = Flask(__name__)
     app = Flask(__name__)
     app.config.update(
     app.config.update(

+ 4 - 2
taipy/rest/rest.py

@@ -8,6 +8,8 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
+from flask import Flask
+
 from taipy.config import Config
 from taipy.config import Config
 
 
 from .app import create_app as _create_app
 from .app import create_app as _create_app
@@ -18,7 +20,7 @@ class Rest:
     Runnable Rest application serving REST APIs on top of Taipy Core functionalities.
     Runnable Rest application serving REST APIs on top of Taipy Core functionalities.
     """
     """
 
 
-    def __init__(self):
+    def __init__(self) -> None:
         """
         """
         Initialize a REST API server.
         Initialize a REST API server.
 
 
@@ -31,7 +33,7 @@ class Rest:
         However, editing these parameters is only recommended for advanced users. Indeed, the default behavior of the
         However, editing these parameters is only recommended for advanced users. Indeed, the default behavior of the
         REST server without any required configuration satisfies all the standard and basic needs.
         REST server without any required configuration satisfies all the standard and basic needs.
         """
         """
-        self._app = _create_app(
+        self._app: Flask = _create_app(
             Config.global_config.testing or False, Config.global_config.env, Config.global_config.secret_key
             Config.global_config.testing or False, Config.global_config.env, Config.global_config.secret_key
         )
         )
 
 

+ 6 - 5
tests/core/notification/test_events_published.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 from queue import SimpleQueue
 from queue import SimpleQueue
+from typing import Dict, List
 
 
 from taipy.config import Config, Frequency
 from taipy.config import Config, Frequency
 from taipy.core import taipy as tp
 from taipy.core import taipy as tp
@@ -25,11 +26,11 @@ class Snapshot:
     A captured snapshot of the recording core events consumer.
     A captured snapshot of the recording core events consumer.
     """
     """
 
 
-    def __init__(self):
-        self.collected_events = []
-        self.entity_type_collected = {}
-        self.operation_collected = {}
-        self.attr_name_collected = {}
+    def __init__(self) -> None:
+        self.collected_events: List[Event] = []
+        self.entity_type_collected: Dict[EventEntityType, int] = {}
+        self.operation_collected: Dict[EventEntityType, int] = {}
+        self.attr_name_collected: Dict[EventEntityType, int] = {}
 
 
     def capture_event(self, event):
     def capture_event(self, event):
         self.collected_events.append(event)
         self.collected_events.append(event)

+ 1 - 1
tests/gui/e2e/page_scopes/assets2_class_scopes/page1.py

@@ -13,7 +13,7 @@ from taipy.gui import Markdown, Page
 
 
 
 
 class Page1(Page):
 class Page1(Page):
-    def __init__(self):
+    def __init__(self) -> None:
         self.operand_2 = 0
         self.operand_2 = 0
         super().__init__()
         super().__init__()
 
 

+ 1 - 1
tests/gui/e2e/page_scopes/assets2_class_scopes/page2.py

@@ -13,7 +13,7 @@ from taipy.gui import Markdown, Page
 
 
 
 
 class Page2(Page):
 class Page2(Page):
-    def __init__(self):
+    def __init__(self) -> None:
         self.operand_2 = 0
         self.operand_2 = 0
         super().__init__()
         super().__init__()