From faa77b3c085068ed07903b8d4ede9d9cd23f822d Mon Sep 17 00:00:00 2001 From: superstar54 Date: Thu, 28 Nov 2024 16:30:05 +0100 Subject: [PATCH] fix type hints --- src/aiida_pythonjob/data/serializer.py | 2 +- src/aiida_pythonjob/launch.py | 25 +++++++++++++------------ src/aiida_pythonjob/utils.py | 6 +++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/aiida_pythonjob/data/serializer.py b/src/aiida_pythonjob/data/serializer.py index 8064d05..cb56cf3 100644 --- a/src/aiida_pythonjob/data/serializer.py +++ b/src/aiida_pythonjob/data/serializer.py @@ -51,7 +51,7 @@ def get_serializer_from_entry_points() -> dict: eps = get_serializer_from_entry_points() -def serialize_to_aiida_nodes(inputs: dict | None = None) -> dict: +def serialize_to_aiida_nodes(inputs: dict) -> dict: """Serialize the inputs to a dictionary of AiiDA data nodes. Args: diff --git a/src/aiida_pythonjob/launch.py b/src/aiida_pythonjob/launch.py index 651fe4e..c8e9f5c 100644 --- a/src/aiida_pythonjob/launch.py +++ b/src/aiida_pythonjob/launch.py @@ -1,6 +1,6 @@ import inspect import os -from typing import Any, Callable +from typing import Any, Callable, Dict, Optional, Union from aiida.orm import AbstractCode, Computer, FolderData, List, SinglefileData, Str @@ -10,18 +10,19 @@ def prepare_pythonjob_inputs( - function: Callable[..., Any] | None = None, - function_inputs: dict[str, Any] | None = None, - function_outputs: dict[str, Any] | None = None, - code: AbstractCode | None = None, - command_info: dict[str, str] | None = None, - computer: str | Computer = "localhost", - metadata: dict[str, Any] | None = None, - upload_files: dict[str, str] = {}, - process_label: str | None = None, - pickled_function: PickledFunction | None = None, + function: Optional[Callable[..., Any]] = None, + function_inputs: Optional[Dict[str, Any]] = None, + function_outputs: Optional[Dict[str, Any]] = None, + code: Optional[AbstractCode] = None, + command_info: Optional[Dict[str, str]] = None, + computer: Union[str, Computer] = "localhost", + metadata: Optional[Dict[str, Any]] = None, + upload_files: Dict[str, str] = {}, + process_label: Optional[str] = None, + pickled_function: Optional[PickledFunction] = None, **kwargs: Any, -) -> dict[str, Any]: +) -> Dict[str, Any]: + pass """Prepare the inputs for PythonJob""" if function is None and pickled_function is None: diff --git a/src/aiida_pythonjob/utils.py b/src/aiida_pythonjob/utils.py index 5c170b9..873238b 100644 --- a/src/aiida_pythonjob/utils.py +++ b/src/aiida_pythonjob/utils.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Optional, Union from aiida.common.exceptions import NotExistent from aiida.orm import Computer, InstalledCode, load_code, load_computer @@ -6,10 +6,10 @@ def get_or_create_code( label: str = "python3", - computer: Optional[str | Computer] = "localhost", + computer: Optional[Union[str, "Computer"]] = "localhost", filepath_executable: Optional[str] = None, prepend_text: str = "", -): +) -> InstalledCode: """Try to load code, create if not exit.""" try: