Jelajahi Sumber

Removing useless type annotation (#1193)

Add None return type to init methods
Jean-Robin 1 tahun lalu
induk
melakukan
4278574124
41 mengubah file dengan 96 tambahan dan 87 penghapusan
  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:
     DEFAULT_KEY = "default"
 
-    def __init__(self):
+    def __init__(self) -> None:
         self._sections: Dict[str, Dict[str, Section]] = {}
         self._unique_sections: Dict[str, UniqueSection] = {}
         self._global_config: GlobalAppConfig = GlobalAppConfig()
 
-    def _clean(self):
+    def _clean(self) -> None:
         self._global_config._clean()
         for unique_section in self._unique_sections.values():
             unique_section._clean()
@@ -39,7 +39,7 @@ class _Config:
         config._global_config = GlobalAppConfig.default_config()
         return config
 
-    def _update(self, other_config):
+    def _update(self, other_config) -> None:
         self._global_config._update(other_config._global_config._to_dict())
         if other_config._unique_sections:
             for section_name, other_section in other_config._unique_sections.items():
@@ -55,12 +55,12 @@ class _Config:
                     self._sections[section_name] = {}
                     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():
             entity_config[cfg_id] = copy(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 entity_config:
                 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))
             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.
         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:
-    def __init__(self):
+    def __init__(self) -> None:
         self._unconflicted_sections: Set[str] = set()
         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):
             section_name = {section_name}
 

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

@@ -29,7 +29,7 @@ class IssueCollector:
     _WARNING_LEVEL = "WARNING"
     _INFO_LEVEL = "INFO"
 
-    def __init__(self):
+    def __init__(self) -> None:
         self._errors: List[Issue] = []
         self._warnings: List[Issue] = []
         self._infos: List[Issue] = []
@@ -50,11 +50,11 @@ class IssueCollector:
     def errors(self) -> List[Issue]:
         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))
 
-    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))
 
-    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))

+ 4 - 4
taipy/config/config.pyi

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

+ 1 - 1
taipy/core/_core.py

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

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

@@ -11,16 +11,21 @@
 
 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:
-    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):
         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
 
 
-def _self_reload(manager):
+def _self_reload(manager: str):
     def __reload(fct):
         @functools.wraps(fct)
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_VersionModel, converter=_VersionConverter, dir_name="version")
 
     @property

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

@@ -19,7 +19,7 @@ from ._version_repository_interface import _VersionRepositoryInterface
 
 
 class _VersionSQLRepository(_SQLRepository, _VersionRepositoryInterface):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_VersionModel, converter=_VersionConverter)
 
     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.
 
 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.common._template_handler import _TemplateHandler as _tpl
@@ -53,12 +53,12 @@ class TaskConfig(Section):
     def __init__(
         self,
         id: str,
-        function,
+        function: Optional[Callable],
         inputs: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         outputs: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
-    ):
+    ) -> None:
         if inputs:
             self._inputs = [inputs] if isinstance(inputs, DataNodeConfig) else copy(inputs)
         else:
@@ -71,8 +71,8 @@ class TaskConfig(Section):
                 skippable = True
         else:
             self._outputs = []
-        self._skippable = skippable
-        self.function = function
+        self._skippable: bool = skippable
+        self.function: Optional[Callable] = function
         super().__init__(id, **properties)
 
     def __copy__(self):
@@ -100,14 +100,14 @@ class TaskConfig(Section):
         return list(self._outputs)
 
     @property
-    def skippable(self):
+    def skippable(self) -> bool:
         return _tpl._replace_templates(self._skippable)
 
     @classmethod
     def default_config(cls):
         return TaskConfig(cls._DEFAULT_KEY, None, [], [], False)
 
-    def _clean(self):
+    def _clean(self) -> None:
         self.function = None
         self._inputs = []
         self._outputs = []
@@ -158,10 +158,10 @@ class TaskConfig(Section):
     @staticmethod
     def _configure(
         id: str,
-        function,
+        function: Optional[Callable],
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
     ) -> "TaskConfig":
         """Configure a new task configuration.
@@ -189,10 +189,10 @@ class TaskConfig(Section):
 
     @staticmethod
     def _set_default_configuration(
-        function,
+        function: Optional[Callable],
         input: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
         output: Optional[Union[DataNodeConfig, List[DataNodeConfig]]] = None,
-        skippable: Optional[bool] = False,
+        skippable: bool = False,
         **properties,
     ) -> "TaskConfig":
         """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):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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 = "_"
     __logger = _TaipyLogger._get_logger()
     _REQUIRED_PROPERTIES: List[str] = []
-    _MANAGER_NAME = "data"
+    _MANAGER_NAME: str = "data"
     __PATH_KEY = "path"
     __EDIT_TIMEOUT = 30
 
@@ -103,7 +103,7 @@ class DataNode(_Entity, _Labeled):
         editor_id: Optional[str] = None,
         editor_expiration_date: Optional[datetime] = None,
         **kwargs,
-    ):
+    ) -> None:
         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._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):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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.
 
         Parameters:
@@ -61,16 +61,16 @@ class CoreEventConsumerBase(threading.Thread):
         self.__STOP_FLAG = False
         self._TIMEOUT = 0.1
 
-    def start(self):
+    def start(self) -> None:
         """Start the event consumer thread."""
         self.__STOP_FLAG = False
         threading.Thread.start(self)
 
-    def stop(self):
+    def stop(self) -> None:
         """Stop the event consumer thread."""
         self.__STOP_FLAG = True
 
-    def run(self):
+    def run(self) -> None:
         while not self.__STOP_FLAG:
             try:
                 event: Event = self.queue.get(block=True, timeout=self._TIMEOUT)
@@ -79,6 +79,6 @@ class CoreEventConsumerBase(threading.Thread):
                 pass
 
     @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."""
         raise NotImplementedError

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

@@ -14,5 +14,5 @@ from ._scenario_model import _ScenarioModel
 
 
 class _ScenarioFSRepository(_FileSystemRepository):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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_type: str,
         entity_config_id: Optional[str] = None,
-        id: Optional[str] = None,
+        id: Optional[SubmissionId] = None,
         jobs: Optional[Union[List[Job], List[JobId]]] = None,
         properties: Optional[Dict[str, Any]] = None,
         creation_date: Optional[datetime] = None,
@@ -80,7 +80,7 @@ class Submission(_Entity, _Labeled):
         self._pending_jobs: Set = set()
 
     @staticmethod
-    def __new_id() -> str:
+    def __new_id() -> SubmissionId:
         """Generate a unique Submission identifier."""
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         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
 # 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.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]
                 ]
                 skippable = task_config.skippable
+
                 task = Task(
                     str(task_config.id),
                     dict(**task_config._properties),
-                    task_config.function,
+                    cast(Callable, task_config.function),
                     inputs,
                     outputs,
                     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):
-    def __init__(self):
+    def __init__(self) -> None:
         super().__init__(model_type=_TaskModel, converter=_TaskConverter)

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

@@ -58,7 +58,7 @@ class Task(_Entity, _Labeled):
         self,
         config_id: str,
         properties: Dict[str, Any],
-        function,
+        function: Callable,
         input: Optional[Iterable[DataNode]] = None,
         output: Optional[Iterable[DataNode]] = None,
         id: Optional[TaskId] = None,
@@ -66,7 +66,7 @@ class Task(_Entity, _Labeled):
         parent_ids: Optional[Set[str]] = None,
         version: Optional[str] = None,
         skippable: bool = False,
-    ):
+    ) -> None:
         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._owner_id = owner_id

+ 1 - 1
taipy/gui/_page.py

@@ -22,7 +22,7 @@ if t.TYPE_CHECKING:
 
 
 class _Page(object):
-    def __init__(self):
+    def __init__(self) -> None:
         self._rendered_jsx: t.Optional[str] = None
         self._renderer: t.Optional[Page] = 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):
-    def __init__(self):
+    def __init__(self) -> None:
         self._adapters: t.List[JsonAdapter] = []
         self.register(_DefaultJsonAdapter())
 

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

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

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

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

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

@@ -38,7 +38,7 @@ class _Element(ABC):
             parent.add(obj)
         return obj
 
-    def __init__(self, *args, **kwargs):
+    def __init__(self, *args, **kwargs) -> None:
         self._properties: t.Dict[str, t.Any] = {}
         if args and self._DEFAULT_PROPERTY != "":
             self._properties = {self._DEFAULT_PROPERTY: args[0]}
@@ -81,7 +81,7 @@ class _Element(ABC):
 class _Block(_Element):
     """NOT DOCUMENTED"""
 
-    def __init__(self, *args, **kwargs):
+    def __init__(self, *args, **kwargs) -> None:
         super().__init__(*args, **kwargs)
         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])$"
     )
 
-    def __init__(self):
+    def __init__(self) -> None:
         self.pages: t.List[_Page] = []
         self.root_page: t.Optional[_Page] = None
         self.routes: t.List[str] = []

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

@@ -19,7 +19,7 @@ from . import _MapDict
 
 
 class _Adapter:
-    def __init__(self):
+    def __init__(self) -> None:
         self.__adapter_for_type: t.Dict[str, t.Callable] = {}
         self.__type_for_variable: t.Dict[str, str] = {}
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         self.__port_gui: t.Dict[int, "Gui"] = {}
 
     def add_gui(self, gui: "Gui", port: int):

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

@@ -11,15 +11,15 @@
 
 
 class ConfigIdMissingException(Exception):
-    def __init__(self):
+    def __init__(self) -> None:
         self.message = "Config id is missing."
 
 
 class ScenarioIdMissingException(Exception):
-    def __init__(self):
+    def __init__(self) -> None:
         self.message = "Scenario id is missing."
 
 
 class SequenceNameMissingException(Exception):
-    def __init__(self):
+    def __init__(self) -> None:
         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
 
 
-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"""
     app = Flask(__name__)
     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
 # 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.
+from flask import Flask
+
 from taipy.config import Config
 
 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.
     """
 
-    def __init__(self):
+    def __init__(self) -> None:
         """
         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
         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
         )
 

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

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 
 from queue import SimpleQueue
+from typing import Dict, List
 
 from taipy.config import Config, Frequency
 from taipy.core import taipy as tp
@@ -25,11 +26,11 @@ class Snapshot:
     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):
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         self.operand_2 = 0
         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):
-    def __init__(self):
+    def __init__(self) -> None:
         self.operand_2 = 0
         super().__init__()