aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/importers/arabesque.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 12:57:32 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 16:46:07 -0700
commitcaf1cb316ed18820f3239a285ef14bf45ef963a2 (patch)
tree2d3713773dac769878154f61c2eb9f7804f1a60c /python/fatcat_tools/importers/arabesque.py
parent10a2374051568edf3d872988e730328d899a0fdd (diff)
downloadfatcat-caf1cb316ed18820f3239a285ef14bf45ef963a2.tar.gz
fatcat-caf1cb316ed18820f3239a285ef14bf45ef963a2.zip
typing: initial annotations on importers
This commit just adds the type annotations, doesn't do fixes to code to make type checking pass.
Diffstat (limited to 'python/fatcat_tools/importers/arabesque.py')
-rw-r--r--python/fatcat_tools/importers/arabesque.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/python/fatcat_tools/importers/arabesque.py b/python/fatcat_tools/importers/arabesque.py
index ae4f9049..2fb7be55 100644
--- a/python/fatcat_tools/importers/arabesque.py
+++ b/python/fatcat_tools/importers/arabesque.py
@@ -1,4 +1,7 @@
+from typing import Any, Dict, List, Optional
+
import fatcat_openapi_client
+from fatcat_openapi_client import ApiClient, FileEntity
from .common import SANE_MAX_RELEASES, SANE_MAX_URLS, EntityImporter, b32_hex, make_rel_url
@@ -36,7 +39,9 @@ class ArabesqueMatchImporter(EntityImporter):
- a mode to insert bare files even if identifier not known?
"""
- def __init__(self, api, extid_type, require_grobid=True, **kwargs):
+ def __init__(
+ self, api: ApiClient, extid_type: str, require_grobid: bool = True, **kwargs
+ ) -> None:
eg_desc = (
kwargs.get("editgroup_description", None)
@@ -59,7 +64,7 @@ class ArabesqueMatchImporter(EntityImporter):
else:
print("NOT checking GROBID status column")
- def want(self, row):
+ def want(self, row: Any) -> bool:
if self.require_grobid and not row["postproc_status"] == "200":
return False
if (
@@ -76,7 +81,7 @@ class ArabesqueMatchImporter(EntityImporter):
else:
return False
- def parse_record(self, row):
+ def parse_record(self, row: Dict[str, Any]) -> Optional[FileEntity]:
extid = row["identifier"].strip()
@@ -131,7 +136,7 @@ class ArabesqueMatchImporter(EntityImporter):
)
return fe
- def try_update(self, fe):
+ def try_update(self, fe: FileEntity) -> bool:
# lookup sha1, or create new entity
existing = None
try:
@@ -182,7 +187,7 @@ class ArabesqueMatchImporter(EntityImporter):
self.counts["update"] += 1
return False
- def insert_batch(self, batch):
+ def insert_batch(self, batch: List[FileEntity]) -> None:
self.api.create_file_auto_batch(
fatcat_openapi_client.FileAutoBatch(
editgroup=fatcat_openapi_client.Editgroup(