added typeddict for context data

This commit is contained in:
Jakub Trllo 2025-06-16 14:48:37 +02:00
parent 34d9289f3c
commit 09858f61e1

View file

@ -15,6 +15,13 @@ from ayon_core.lib import emit_event
if typing.TYPE_CHECKING:
from ayon_core.pipeline import Anatomy
from typing import TypedDict
class HostContextData(TypedDict):
project_name: str
folder_path: Optional[str]
task_name: Optional[str]
@dataclass
class ContextChangeData:
@ -141,7 +148,7 @@ class HostBase(ABC):
return os.environ.get("AYON_TASK_NAME")
def get_current_context(self) -> dict[str, Optional[str]]:
def get_current_context(self) -> "HostContextData":
"""Get current context information.
This method should be used to get current context of host. Usage of
@ -168,7 +175,7 @@ class HostBase(ABC):
reason: Optional[str] = None,
project_entity: Optional[dict[str, Any]] = None,
anatomy: Optional[Anatomy] = None,
) -> dict[str, Optional[str]]:
) -> "HostContextData":
"""Set current context information.
This method should be used to set current context of host. Usage of
@ -281,7 +288,7 @@ class HostBase(ABC):
project_name: str,
folder_path: Optional[str],
task_name: Optional[str],
):
) -> "HostContextData":
"""Emit context change event.
Args:
@ -289,6 +296,9 @@ class HostBase(ABC):
folder_path (Optional[str]): Path of the folder.
task_name (Optional[str]): Name of the task.
Returns:
HostContextData: Data send to context change event.
"""
data = {
"project_name": project_name,