Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Fix type checking syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinclert committed May 7, 2024
1 parent 78413e3 commit 317ecac
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/dialect_map_core/storage/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def load(self, file_path: str) -> list:
with open(file_path) as file:
records = json.load(file)

if type(records) != list:
if type(records) is not list:
records = [records]

# Decode strings into corresponding Python objects
Expand Down
4 changes: 2 additions & 2 deletions tests/controllers/test_jargon_ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def test_create_nested(self, session: BaseDatabaseSession):
created_jargon = jargon_controller.get(jargon_id)

assert created_group_id == group_id
assert type(created_group) == JargonGroup
assert type(created_jargon) == Jargon
assert type(created_group) is JargonGroup
assert type(created_jargon) is Jargon

def test_delete(self, controller: JargonGroupController):
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/test_metrics_ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_get_by_jargon(self, controller: JargonCategoryMetricsController):
all_metrics = controller.get_by_jargon("jargon-01234", "category-01234")
one_metric = all_metrics[0]

assert type(all_metrics) == list
assert type(all_metrics) is list
assert type(one_metric) is JargonCategoryMetrics
assert one_metric.id == "jargon-cat-metric-01234"

Expand Down Expand Up @@ -110,7 +110,7 @@ def test_get_by_jargon(self, controller: JargonPaperMetricsController):
all_metrics = controller.get_by_jargon("jargon-01234", "paper-01234", 1)
one_metric = all_metrics[0]

assert type(all_metrics) == list
assert type(all_metrics) is list
assert type(one_metric) is JargonPaperMetrics
assert one_metric.id == "jargon-paper-metric-00001"

Expand All @@ -122,7 +122,7 @@ def test_get_latest(self, controller: JargonPaperMetricsController):

all_metrics = controller.get_latest_by_jargon("jargon-01234")

assert type(all_metrics) == list
assert type(all_metrics) is list
assert len(all_metrics) > 0
assert all(m.arxiv_rev > 1 for m in all_metrics)

Expand Down
4 changes: 2 additions & 2 deletions tests/controllers/test_paper_ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_get(self, controller: PaperAuthorController):
all_authors = controller.get_by_paper("paper-01234", 1)
one_author = all_authors[0]

assert type(all_authors) == list
assert type(all_authors) is list
assert type(one_author) is PaperAuthor
assert one_author.id == "paper-author-01234-A"

Expand Down Expand Up @@ -187,7 +187,7 @@ def test_get(self, controller: PaperReferenceCountersController):
all_counters = controller.get_by_paper("paper-01234", 1)
one_counter = all_counters[0]

assert type(all_counters) == list
assert type(all_counters) is list
assert type(one_counter) is PaperReferenceCounters
assert one_counter.id == "paper-ref-counter-01234-A"

Expand Down
4 changes: 2 additions & 2 deletions tests/controllers/test_reference_ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_get_by_source(self, controller: ReferenceController):
all_refs = controller.get_by_source_paper(paper_id, paper_rev)
one_ref = all_refs[0]

assert type(all_refs) == list
assert type(all_refs) is list
assert type(one_ref) is PaperReference
assert one_ref.source_arxiv_id == paper_id
assert one_ref.source_arxiv_rev == paper_rev
Expand All @@ -67,7 +67,7 @@ def test_get_by_target(self, controller: ReferenceController):
all_refs = controller.get_by_target_paper(paper_id, paper_rev)
one_ref = all_refs[0]

assert type(all_refs) == list
assert type(all_refs) is list
assert type(one_ref) is PaperReference
assert one_ref.target_arxiv_id == paper_id
assert one_ref.target_arxiv_rev == paper_rev
Expand Down
6 changes: 3 additions & 3 deletions tests/encoding/test_json_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def test_json_decoding():
s2 = "2020-11-20"
s3 = "2020-11-20 14:00:00"

assert type(decoder.custom_decode(s1)) == str
assert type(decoder.custom_decode(s2)) == date
assert type(decoder.custom_decode(s3)) == datetime
assert type(decoder.custom_decode(s1)) is str
assert type(decoder.custom_decode(s2)) is date
assert type(decoder.custom_decode(s3)) is datetime


def test_json_decoding_dates():
Expand Down
6 changes: 3 additions & 3 deletions tests/encoding/test_json_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def test_python_encoding():
o2 = "example"
o3 = 100

assert type(encoder.custom_encode(o1)) == str
assert type(encoder.custom_encode(o2)) == str
assert type(encoder.custom_encode(o3)) == str
assert type(encoder.custom_encode(o1)) is str
assert type(encoder.custom_encode(o2)) is str
assert type(encoder.custom_encode(o3)) is str


def test_python_encoding_dates():
Expand Down
4 changes: 2 additions & 2 deletions tests/storage/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def test_valid_transaction_committed(
)
)

assert type(ctl.get("example-1")) == Category
assert type(ctl.get("example-2")) == Category
assert type(ctl.get("example-1")) is Category
assert type(ctl.get("example-2")) is Category

def test_valid_transaction_uncommitted(
self,
Expand Down

0 comments on commit 317ecac

Please sign in to comment.