Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Sep 29, 2024
1 parent a0bb178 commit 5459015
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
12 changes: 9 additions & 3 deletions application/defs/cre_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,17 @@ def add_link(self, link: Link) -> "Document":
if not self.links:
self.links = []
if not isinstance(link, Link):
raise ValueError(f"add_link only takes Link() types, instead it was provided with '{type(link)}', that's an internal bug, please open a ticket")
raise ValueError(
f"add_link only takes Link() types, instead it was provided with '{type(link)}', that's an internal bug, please open a ticket"
)
if link.document.id == self.id:
raise ValueError(f"Cannot link a document to itself, {self.id} is the same as the link")
raise ValueError(
f"Cannot link a document to itself, {self.id} is the same as the link"
)
if link.document.id in [l.document.id for l in self.links]:
raise cre_exceptions.DuplicateLinkException(f"Cannot link the same document twice, document {link.document.id} is already linked to {self.id}")
raise cre_exceptions.DuplicateLinkException(
f"Cannot link the same document twice, document {link.document.id} is already linked to {self.id}"
)

self.links.append(link)
return self
Expand Down
24 changes: 20 additions & 4 deletions application/tests/cre_main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ def test_register_cre(self) -> None:

self.assertCountEqual(
c_higher.links,
[defs.Link(document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.Contains)],
[
defs.Link(
document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.Contains
)
],
)
self.assertCountEqual(
retrieved_cre.links,
Expand All @@ -286,15 +290,27 @@ def test_register_cre(self) -> None:

self.assertCountEqual(
c_lower.links,
[defs.Link(document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.PartOf)],
[
defs.Link(
document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.PartOf
)
],
)
self.assertCountEqual(
c_higher.links,
[defs.Link(document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.Contains)],
[
defs.Link(
document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.Contains
)
],
)
self.assertCountEqual(
c_equal.links,
[defs.Link(document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.Related)],
[
defs.Link(
document=retrieved_cre.shallow_copy(), ltype=defs.LinkTypes.Related
)
],
)

def test_parse_file(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion application/web/web_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def import_from_cre_csv() -> Any:
try:
documents = spreadsheet_parsers.parse_export_format(list(csv_read))
except cre_exceptions.DuplicateLinkException as dle:
abort(500,f"error during parsing of the incoming CSV, err:{dle}")
abort(500, f"error during parsing of the incoming CSV, err:{dle}")
cres = documents.pop(defs.Credoctypes.CRE.value)

standards = documents
Expand Down
1 change: 1 addition & 0 deletions application/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

listen = ["high", "default", "low"]


def start_worker():
logger.info(f"Worker Starting")
with Connection(redis.connect()):
Expand Down

0 comments on commit 5459015

Please sign in to comment.