diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-03 13:57:18 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-03 16:46:07 -0700 |
commit | 5d29d1336afc90d3575a0379a9e9d9bdac8d1856 (patch) | |
tree | c22755cdf2615453ab1f3b7ddaf13becd946a63d /python/fatcat_tools/importers/grobid_metadata.py | |
parent | caf1cb316ed18820f3239a285ef14bf45ef963a2 (diff) | |
download | fatcat-5d29d1336afc90d3575a0379a9e9d9bdac8d1856.tar.gz fatcat-5d29d1336afc90d3575a0379a9e9d9bdac8d1856.zip |
typing: relatively simple type check fixes
These mostly add new variable names so that existing variables aren't
overwritten with a new type; delay coercing '{}' or '[]' to 'None' until
the last minute; adding is-not-None checks to conditional clauses; and
similar small changes.
Diffstat (limited to 'python/fatcat_tools/importers/grobid_metadata.py')
-rw-r--r-- | python/fatcat_tools/importers/grobid_metadata.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/python/fatcat_tools/importers/grobid_metadata.py b/python/fatcat_tools/importers/grobid_metadata.py index 830c9bbb..e36e1b48 100644 --- a/python/fatcat_tools/importers/grobid_metadata.py +++ b/python/fatcat_tools/importers/grobid_metadata.py @@ -88,7 +88,7 @@ class GrobidMetadataImporter(EntityImporter): ) abstracts = [abobj] else: - abstracts = None + abstracts = [] contribs = [] for i, a in enumerate(obj.get("authors", [])): @@ -118,14 +118,12 @@ class GrobidMetadataImporter(EntityImporter): if raw.get("authors"): cite_extra["authors"] = [clean(a["name"]) for a in raw["authors"]] - if not cite_extra: - cite_extra = None refs.append( fatcat_openapi_client.ReleaseRef( key=clean(raw.get("id")), year=year, title=clean(raw["title"]), - extra=cite_extra, + extra=cite_extra or None, ) ) @@ -147,12 +145,11 @@ class GrobidMetadataImporter(EntityImporter): extra["grobid"] = extra_grobid if self.longtail_oa: extra["longtail_oa"] = True - if not extra: - extra = None - title = clean(obj["title"], force_xml=True) - if not title or len(title) < 2: + clean_title = clean(obj["title"], force_xml=True) + if not clean_title or len(clean_title) < 2: return None + title = clean_title re = fatcat_openapi_client.ReleaseEntity( title=title, |