aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/transforms
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-04-16 18:34:45 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-02 17:02:49 -0700
commit8e2fd41d10725b65c787ae56cb9320fbcc182288 (patch)
treef96d70bbd62ce932f88ae90d49cc00974ae2452d /python/fatcat_tools/transforms
parent8a23a460d6a5721dae1fed52c69c3c1f8d85ad30 (diff)
downloadfatcat-8e2fd41d10725b65c787ae56cb9320fbcc182288.tar.gz
fatcat-8e2fd41d10725b65c787ae56cb9320fbcc182288.zip
try some type annotations
Diffstat (limited to 'python/fatcat_tools/transforms')
-rw-r--r--python/fatcat_tools/transforms/elasticsearch.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/python/fatcat_tools/transforms/elasticsearch.py b/python/fatcat_tools/transforms/elasticsearch.py
index f7c8e3f3..26eacded 100644
--- a/python/fatcat_tools/transforms/elasticsearch.py
+++ b/python/fatcat_tools/transforms/elasticsearch.py
@@ -1,6 +1,6 @@
import datetime
-from typing import Optional
+from typing import Dict, List, Any, Optional
import tldextract
@@ -24,7 +24,7 @@ def test_check_kbart() -> None:
assert check_kbart(1950, dict(year_spans=[[1900, 1920], [1930, 2000]])) is True
-def release_to_elasticsearch(entity: ReleaseEntity, force_bool: bool = True) -> dict:
+def release_to_elasticsearch(entity: ReleaseEntity, force_bool: bool = True) -> Dict[str, Any]:
"""
Converts from an entity model/schema to elasticsearch oriented schema.
@@ -45,7 +45,7 @@ def release_to_elasticsearch(entity: ReleaseEntity, force_bool: bool = True) ->
# First, the easy ones (direct copy)
release = entity
- t = dict(
+ t: Dict[str, Any] = dict(
doc_index_ts=datetime.datetime.utcnow().isoformat()+"Z",
ident = release.ident,
state = release.state,
@@ -510,7 +510,7 @@ def container_to_elasticsearch(entity, force_bool=True, stats=None):
return t
-def _type_of_edit(edit):
+def _type_of_edit(edit: EntityEdit) -> str:
if edit.revision == None and edit.redirect_ident == None:
return 'delete'
elif edit.redirect_ident:
@@ -522,7 +522,7 @@ def _type_of_edit(edit):
return 'update'
-def changelog_to_elasticsearch(entity):
+def changelog_to_elasticsearch(entity: ChangelogEntry) -> Dict[str, Any]:
"""
Note that this importer requires expanded fill info to work. Calling code
may need to re-fetch editgroup from API to get the 'editor' field. Some of
@@ -577,7 +577,7 @@ def changelog_to_elasticsearch(entity):
return t
-def file_to_elasticsearch(entity):
+def file_to_elasticsearch(entity: FileEntity) -> Dict[str, Any]:
"""
Converts from an entity model/schema to elasticsearch oriented schema.