aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
Diffstat (limited to 'fatcat_scholar')
-rw-r--r--fatcat_scholar/hacks.py6
-rw-r--r--fatcat_scholar/identifiers.py28
-rw-r--r--fatcat_scholar/issue_db.py4
-rw-r--r--fatcat_scholar/schema.py20
-rw-r--r--fatcat_scholar/search.py2
-rw-r--r--fatcat_scholar/sim_pipeline.py2
-rw-r--r--fatcat_scholar/transform.py6
-rw-r--r--fatcat_scholar/work_pipeline.py4
8 files changed, 36 insertions, 36 deletions
diff --git a/fatcat_scholar/hacks.py b/fatcat_scholar/hacks.py
index 541edda..2be90f0 100644
--- a/fatcat_scholar/hacks.py
+++ b/fatcat_scholar/hacks.py
@@ -68,8 +68,8 @@ def parse_accept_lang(header: str, options: typing.List[str]) -> typing.Optional
def test_parse_accept_lang() -> None:
- assert parse_accept_lang("", []) == None
- assert parse_accept_lang("en,de", []) == None
+ assert parse_accept_lang("", []) is None
+ assert parse_accept_lang("en,de", []) is None
assert parse_accept_lang("en,de", ["en"]) == "en"
assert parse_accept_lang("en-GB,de", ["en"]) == "en"
assert parse_accept_lang("zh_Hans_CN", ["en", "zh"]) == "zh"
@@ -94,7 +94,7 @@ def wayback_direct_url(url: str) -> str:
"""
Re-writes a wayback replay URL to add the 'id_' suffix (or equivalent for direct file access)
"""
- if not "://web.archive.org" in url:
+ if "://web.archive.org" not in url:
return url
segments = url.split("/")
if len(segments) < 6 or not segments[4].isdigit():
diff --git a/fatcat_scholar/identifiers.py b/fatcat_scholar/identifiers.py
index 9a64de8..d1a1197 100644
--- a/fatcat_scholar/identifiers.py
+++ b/fatcat_scholar/identifiers.py
@@ -24,7 +24,7 @@ def clean_doi(raw: Optional[str]) -> Optional[str]:
return None
if len(raw.split()) != 1:
return None
- if not "10." in raw:
+ if "10." not in raw:
return None
if not raw.startswith("10."):
raw = raw[raw.find("10.") :]
@@ -51,23 +51,23 @@ def clean_doi(raw: Optional[str]) -> Optional[str]:
def test_clean_doi() -> None:
- assert clean_doi(None) == None
- assert clean_doi("") == None
- assert clean_doi("asdf") == None
- assert clean_doi("10.123") == None
+ assert clean_doi(None) is None
+ assert clean_doi("") is None
+ assert clean_doi("asdf") is None
+ assert clean_doi("10.123") is None
assert clean_doi("10.1234/asdf ") == "10.1234/asdf"
assert clean_doi("10.1234/ASdf ") == "10.1234/asdf"
assert clean_doi("10.1037//0002-9432.72.1.50") == "10.1037/0002-9432.72.1.50"
assert clean_doi("10.1037/0002-9432.72.1.50") == "10.1037/0002-9432.72.1.50"
- assert clean_doi("10.23750/abm.v88i2 -s.6506") == None
- assert clean_doi("10.17167/mksz.2017.2.129–155") == None
+ assert clean_doi("10.23750/abm.v88i2 -s.6506") is None
+ assert clean_doi("10.17167/mksz.2017.2.129–155") is None
assert clean_doi("http://doi.org/10.1234/asdf ") == "10.1234/asdf"
assert clean_doi("https://dx.doi.org/10.1234/asdf ") == "10.1234/asdf"
assert clean_doi("doi:10.1234/asdf ") == "10.1234/asdf"
- assert clean_doi("doi:10.1234/ asdf ") == None
- assert clean_doi("10.4149/gpb¬_2017042") == None # "logical negation" character
+ assert clean_doi("doi:10.1234/ asdf ") is None
+ assert clean_doi("10.4149/gpb¬_2017042") is None # "logical negation" character
assert (
- clean_doi("10.6002/ect.2020.häyry") == None
+ clean_doi("10.6002/ect.2020.häyry") is None
) # this example via pubmed (pmid:32519616)
# GROBID mangled DOI
assert clean_doi("21924DOI10.1234/asdf ") == "10.1234/asdf"
@@ -85,9 +85,9 @@ def clean_pmcid(raw: Optional[str]) -> Optional[str]:
def test_clean_pmcid() -> None:
- assert clean_pmcid("10.1234/asdf ") == None
- assert clean_pmcid("") == None
- assert clean_pmcid("1 2") == None
- assert clean_pmcid(None) == None
+ assert clean_pmcid("10.1234/asdf ") is None
+ assert clean_pmcid("") is None
+ assert clean_pmcid("1 2") is None
+ assert clean_pmcid(None) is None
assert clean_pmcid("PMC123") == "PMC123"
assert clean_pmcid("pmc123") == "PMC123"
diff --git a/fatcat_scholar/issue_db.py b/fatcat_scholar/issue_db.py
index 3ca6b79..320c98d 100644
--- a/fatcat_scholar/issue_db.py
+++ b/fatcat_scholar/issue_db.py
@@ -255,7 +255,7 @@ class IssueDB:
if not line:
continue
obj = json.loads(line)
- if not "metadata" in obj:
+ if "metadata" not in obj:
continue
meta = obj["metadata"]
assert "periodicals" in meta["collection"]
@@ -293,7 +293,7 @@ class IssueDB:
if not line:
continue
obj = json.loads(line)
- if not "metadata" in obj:
+ if "metadata" not in obj:
continue
meta = obj["metadata"]
assert "periodicals" in meta["collection"]
diff --git a/fatcat_scholar/schema.py b/fatcat_scholar/schema.py
index 633d30b..569cc10 100644
--- a/fatcat_scholar/schema.py
+++ b/fatcat_scholar/schema.py
@@ -313,15 +313,15 @@ def clean_small_int(raw: Optional[str]) -> Optional[int]:
def test_clean_small_int() -> None:
- assert clean_small_int("") == None
- assert clean_small_int(None) == None
- assert clean_small_int("asdf") == None
- assert clean_small_int("iiv") == None
+ assert clean_small_int("") is None
+ assert clean_small_int(None) is None
+ assert clean_small_int("asdf") is None
+ assert clean_small_int("iiv") is None
assert clean_small_int("123") == 123
- assert clean_small_int("1200003") == None
- assert clean_small_int("-123") == None
- assert clean_small_int("48844") == None
- assert clean_small_int("1990²") == None
+ assert clean_small_int("1200003") is None
+ assert clean_small_int("-123") is None
+ assert clean_small_int("48844") is None
+ assert clean_small_int("1990²") is None
def doi_split_prefix(doi: str) -> str:
@@ -356,8 +356,8 @@ def clean_url_conservative(url: Optional[str]) -> Optional[str]:
def test_clean_url_conservative() -> None:
- assert clean_url_conservative("") == None
- assert clean_url_conservative(None) == None
+ assert clean_url_conservative("") is None
+ assert clean_url_conservative(None) is None
assert (
clean_url_conservative("<http://en.wikipedia.org/wiki/Rumpelstiltskin>")
== "http://en.wikipedia.org/wiki/Rumpelstiltskin"
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index 5c7aba0..c49bd98 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -232,7 +232,7 @@ def process_query(query: FulltextQuery) -> FulltextHits:
return do_fulltext_search(query)
# try handling raw identifier queries
- if len(query.q.strip().split()) == 1 and not '"' in query.q:
+ if len(query.q.strip().split()) == 1 and '"' not in query.q:
doi = clean_doi(query.q)
if doi:
return do_lookup_query(f'doi:"{doi}"')
diff --git a/fatcat_scholar/sim_pipeline.py b/fatcat_scholar/sim_pipeline.py
index 9157852..25a46ae 100644
--- a/fatcat_scholar/sim_pipeline.py
+++ b/fatcat_scholar/sim_pipeline.py
@@ -66,7 +66,7 @@ class SimPipeline:
leaf_index = dict()
leaf_list = []
- if not "page_numbers" in issue_meta:
+ if "page_numbers" not in issue_meta:
# TODO: warn
return None
for entry in issue_meta["page_numbers"].get("pages", []):
diff --git a/fatcat_scholar/transform.py b/fatcat_scholar/transform.py
index 3213b8d..f805e7b 100644
--- a/fatcat_scholar/transform.py
+++ b/fatcat_scholar/transform.py
@@ -588,7 +588,7 @@ def transform_heavy(heavy: IntermediateBundle) -> Optional[ScholarDoc]:
file_ident=fulltext.file_ident,
release_ident=fulltext.release_ident,
)
- if ia_sim and not AccessType.ia_sim in access_dict:
+ if ia_sim and AccessType.ia_sim not in access_dict:
access_dict[AccessType.ia_sim] = ScholarAccess(
access_type=AccessType.ia_sim,
access_url=f"https://archive.org/details/{ia_sim.issue_item}/page/{ia_sim.first_page}",
@@ -608,11 +608,11 @@ def transform_heavy(heavy: IntermediateBundle) -> Optional[ScholarDoc]:
for _, acc in access_dict.items():
if "://www.medrxiv.org/" in acc.access_url:
biblio.container_name = "medRxiv"
- if biblio.release_stage == None:
+ if biblio.release_stage is None:
biblio.release_stage = "submitted"
elif "://www.biorxiv.org/" in acc.access_url:
biblio.container_name = "bioRxiv"
- if biblio.release_stage == None:
+ if biblio.release_stage is None:
biblio.release_stage = "submitted"
return ScholarDoc(
diff --git a/fatcat_scholar/work_pipeline.py b/fatcat_scholar/work_pipeline.py
index 191e898..5c32767 100644
--- a/fatcat_scholar/work_pipeline.py
+++ b/fatcat_scholar/work_pipeline.py
@@ -28,7 +28,7 @@ def parse_pages(raw: str) -> Tuple[Optional[int], Optional[int]]:
if not first_raw.isdigit():
return (None, None)
first = int(first_raw)
- if not "-" in raw:
+ if "-" not in raw:
return (first, first)
last_raw = raw.split("-")[-1]
if not last_raw.isdigit():
@@ -301,7 +301,7 @@ class WorkPipeline:
leaf_index = dict()
leaf_list = []
- if not "page_numbers" in issue_meta:
+ if "page_numbers" not in issue_meta:
# TODO: warn
return None
for entry in issue_meta["page_numbers"].get("pages", []):