From 4c90b94c24e9e78382d12947fb27c203318d6c9c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 3 Jun 2020 23:30:44 -0700 Subject: flake8-annotation linting Added some new annotations; need to finish more. --- fatcat_scholar/api_entities.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'fatcat_scholar/api_entities.py') 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) -- cgit v1.2.3