From 411c433d50ed8bf4b0ea84d9872e7b07d17d342c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 6 Jun 2025 17:06:58 +0200 Subject: [PATCH] added typehints --- client/ayon_core/host/host.py | 7 +++++-- client/ayon_core/host/interfaces/workfiles.py | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index f9f74e8069..1c2885b7e6 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -25,7 +25,6 @@ class ContextChangeData: anatomy: "Anatomy" - class HostBase(ABC): """Base of host implementation class. @@ -169,7 +168,7 @@ class HostBase(ABC): reason: Optional[str] = None, project_entity: Optional[dict[str, Any]] = None, anatomy: Optional["Anatomy"] = None, - ): + ) -> dict[str, Optional[str]]: """Set current context information. This method should be used to set current context of host. Usage of @@ -188,6 +187,10 @@ class HostBase(ABC): project_entity (Optional[dict[str, Any]]): Project entity data. anatomy (Optional[Anatomy]): Anatomy instance for the project. + Returns: + dict[str, Optional[str]]: Context information with project name, + folder path and task name. + """ from ayon_core.pipeline import Anatomy diff --git a/client/ayon_core/host/interfaces/workfiles.py b/client/ayon_core/host/interfaces/workfiles.py index f6f6b91f2d..76e91dcd93 100644 --- a/client/ayon_core/host/interfaces/workfiles.py +++ b/client/ayon_core/host/interfaces/workfiles.py @@ -186,7 +186,7 @@ class PublishedWorkfileInfo: file_size: Optional[float], file_modified: Optional[float], file_created: Optional[float], - ): + ) -> "PublishedWorkfileInfo": created_at = arrow.get(repre_entity["createdAt"]).to("local") return cls( @@ -307,7 +307,7 @@ class IWorkfileHost: project_settings: Optional[dict[str, Any]] = None, project_entity: Optional[dict[str, Any]] = None, anatomy: Optional["Anatomy"] = None, - ): + ) -> None: """Save the current workfile with context. Arguments 'rootless_path', 'workfile_entities', 'project_entity' @@ -396,7 +396,7 @@ class IWorkfileHost: project_entity: Optional[dict[str, Any]] = None, project_settings: Optional[dict[str, Any]] = None, anatomy: Optional["Anatomy"] = None, - ): + ) -> None: """Open passed filepath in the host with context. This function should be used to open workfile in different context. @@ -701,7 +701,7 @@ class IWorkfileHost: project_entity: Optional[dict[str, Any]] = None, anatomy: Optional["Anatomy"] = None, open_workfile: bool = True, - ): + ) -> None: """Save workfile path with target folder and task context. It is expected that workfile is saved to the current project, but @@ -797,7 +797,7 @@ class IWorkfileHost: open_workfile: bool = True, src_anatomy: Optional["Anatomy"] = None, src_representation_path: Optional[str] = None, - ): + ) -> None: """Copy workfile representation. Use representation as source for the workfile. @@ -984,7 +984,7 @@ class IWorkfileHost: project_settings: Optional[dict[str, Any]] = None, project_entity: Optional[dict[str, Any]] = None, anatomy: Optional["Anatomy"] = None, - ): + ) -> Optional[dict[str, Any]]: from ayon_core.pipeline.workfile.utils import ( save_workfile_info, find_workfile_rootless_path, @@ -1029,7 +1029,12 @@ class IWorkfileHost: ) return workfile_info - def _create_extra_folders(self, folder_entity, task_entity, workdir): + def _create_extra_folders( + self, + folder_entity: dict[str, Any], + task_entity: dict[str, Any], + workdir: str, + ) -> None: from ayon_core.pipeline.workfile.path_resolving import ( create_workdir_extra_folders ) @@ -1051,7 +1056,7 @@ class IWorkfileHost: folder_entity: dict[str, Any], task_entity: dict[str, Any], filepath: str, - ): + ) -> dict[str, Optional[str]]: workdir, filename = os.path.split(filepath) return { "project_name": project_name,