From 5459015ddf9e80c9e549e40eafd7b338e3adabfd Mon Sep 17 00:00:00 2001 From: Spyros Date: Sun, 29 Sep 2024 11:27:35 +0100 Subject: [PATCH] linting --- application/defs/cre_defs.py | 12 +++++++++--- application/tests/cre_main_test.py | 24 ++++++++++++++++++++---- application/web/web_main.py | 2 +- application/worker.py | 1 + 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/application/defs/cre_defs.py b/application/defs/cre_defs.py index 9e8f00a3..9cf2d4f4 100644 --- a/application/defs/cre_defs.py +++ b/application/defs/cre_defs.py @@ -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 diff --git a/application/tests/cre_main_test.py b/application/tests/cre_main_test.py index 46270fb5..6306a8b0 100644 --- a/application/tests/cre_main_test.py +++ b/application/tests/cre_main_test.py @@ -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, @@ -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: diff --git a/application/web/web_main.py b/application/web/web_main.py index d7225687..ff2da7e9 100644 --- a/application/web/web_main.py +++ b/application/web/web_main.py @@ -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 diff --git a/application/worker.py b/application/worker.py index 76b2057b..96ba7da3 100644 --- a/application/worker.py +++ b/application/worker.py @@ -8,6 +8,7 @@ listen = ["high", "default", "low"] + def start_worker(): logger.info(f"Worker Starting") with Connection(redis.connect()):