diff options
Diffstat (limited to 'fatcat_scholar/api_entities.py')
-rw-r--r-- | fatcat_scholar/api_entities.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fatcat_scholar/api_entities.py b/fatcat_scholar/api_entities.py index df24eda..c4a4ace 100644 --- a/fatcat_scholar/api_entities.py +++ b/fatcat_scholar/api_entities.py @@ -1,11 +1,13 @@ import json import collections +from typing import Any, Optional + from fatcat_openapi_client import ApiClient _global_serde_api_client = ApiClient() -def entity_to_dict(entity, api_client=None): +def entity_to_dict(entity: Any, api_client: Optional[ApiClient] = None) -> dict: """ Hack to take advantage of the code-generated serialization code. @@ -20,7 +22,9 @@ def entity_to_dict(entity, api_client=None): return api_client.sanitize_for_serialization(entity) -def entity_from_json(json_str, entity_type, api_client=None): +def entity_from_json( + json_str: str, entity_type: Any, api_client: Optional[ApiClient] = None +) -> Any: """ Hack to take advantage of the code-generated deserialization code @@ -33,6 +37,8 @@ def entity_from_json(json_str, entity_type, api_client=None): return api_client.deserialize(thing, entity_type) -def entity_from_dict(obj, entity_type, api_client=None): +def entity_from_dict( + obj: dict, entity_type: Any, api_client: Optional[ApiClient] = None +) -> Any: json_str = json.dumps(obj) return entity_from_json(json_str, entity_type, api_client=api_client) |