From 7c5928e09cc7e488d03680c2327c1825f848f6c1 Mon Sep 17 00:00:00 2001 From: "i.nueske" <i.nueske@indiscale.com> Date: Sat, 14 Dec 2024 18:57:23 +0100 Subject: [PATCH] MNT: Replace BaseException with Exception where catching system errors does not seem necessary --- integrationtests/test_base_table_exporter_integration.py | 2 +- integrationtests/test_cache.py | 2 +- integrationtests/test_crawler_basics.py | 2 +- src/caosadvancedtools/crawler.py | 4 ++-- src/caosadvancedtools/export_related.py | 2 +- src/caosadvancedtools/table_export.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integrationtests/test_base_table_exporter_integration.py b/integrationtests/test_base_table_exporter_integration.py index 286c4ac3..0dbfc7e7 100644 --- a/integrationtests/test_base_table_exporter_integration.py +++ b/integrationtests/test_base_table_exporter_integration.py @@ -82,7 +82,7 @@ def setup_module(): """Clear all test entities""" try: db.execute_query("FIND ENTITY Test*").delete() - except BaseException: + except Exception: pass diff --git a/integrationtests/test_cache.py b/integrationtests/test_cache.py index 13470b8b..7724cfb4 100644 --- a/integrationtests/test_cache.py +++ b/integrationtests/test_cache.py @@ -67,7 +67,7 @@ class CacheTest(unittest.TestCase): print(db.execute_query("FIND entity with id="+str(rec.id), unique=True)) try: print(db.execute_query("FIND Record "+str(rec.id), unique=True)) - except BaseException: + except Exception: print("Query does not work as expected") update.insert(cont, run_id) assert len(update.get_updates(run_id)) == 1 diff --git a/integrationtests/test_crawler_basics.py b/integrationtests/test_crawler_basics.py index 04eb5459..67317f32 100644 --- a/integrationtests/test_crawler_basics.py +++ b/integrationtests/test_crawler_basics.py @@ -114,7 +114,7 @@ class CrawlerTest(unittest.TestCase): for el in [self.rec1, self.rec2, self.rec3]: try: el.delete() - except BaseException: + except Exception: pass diff --git a/src/caosadvancedtools/crawler.py b/src/caosadvancedtools/crawler.py index 4214fd9e..ad2536c2 100644 --- a/src/caosadvancedtools/crawler.py +++ b/src/caosadvancedtools/crawler.py @@ -322,7 +322,7 @@ class Crawler(object): except Exception as e: try: DataModelProblems.evaluate_exception(e) - except BaseException: + except Exception: pass logger.debug("Failed during execution of {}!".format( Cfood.__name__)) @@ -354,7 +354,7 @@ class Crawler(object): except Exception as e: try: DataModelProblems.evaluate_exception(e) - except BaseException: + except Exception: pass logger.debug("Failed during execution of {}!".format( cfood.__name__)) diff --git a/src/caosadvancedtools/export_related.py b/src/caosadvancedtools/export_related.py index d25381f9..2114f388 100755 --- a/src/caosadvancedtools/export_related.py +++ b/src/caosadvancedtools/export_related.py @@ -118,7 +118,7 @@ def export(cont, directory="."): try: el.download(target) print("Downloaded:", target) - except BaseException: + except Exception: print("Failed download of:", target) invert_ids(cont) diff --git a/src/caosadvancedtools/table_export.py b/src/caosadvancedtools/table_export.py index 9b821394..78830b19 100644 --- a/src/caosadvancedtools/table_export.py +++ b/src/caosadvancedtools/table_export.py @@ -125,7 +125,7 @@ class BaseTableExporter(object): try: with open(export_dict, encoding="utf-8") as tmp: self.export_dict = json.load(tmp) - except BaseException: + except Exception: raise ValueError( "export_dict must be either a dictionary" " or the path to a json file.") -- GitLab