chore: enable ruff lint rule TRY201 and B904 to improve raise stack traces (#29166)

This commit is contained in:
Maxime Beauchemin
2024-06-12 13:04:42 -07:00
committed by GitHub
parent 5167d20f27
commit 4bb2e2f8af
50 changed files with 152 additions and 141 deletions

View File

@@ -198,15 +198,15 @@ def delete_all_inserted_dashboards():
for dashboard in dashboards_to_delete:
try:
delete_dashboard(dashboard, False)
except Exception as ex:
except Exception:
logger.error(f"failed to delete {dashboard.id}", exc_info=True)
raise ex
raise
if len(inserted_dashboards_ids) > 0:
db.session.commit()
inserted_dashboards_ids.clear()
except Exception as ex2:
except Exception:
logger.error("delete_all_inserted_dashboards failed", exc_info=True)
raise ex2
raise
def delete_dashboard(dashboard: Dashboard, do_commit: bool = False) -> None:
@@ -245,15 +245,15 @@ def delete_all_inserted_slices():
for slice in slices_to_delete:
try:
delete_slice(slice, False)
except Exception as ex:
except Exception:
logger.error(f"failed to delete {slice.id}", exc_info=True)
raise ex
raise
if len(inserted_slices_ids) > 0:
db.session.commit()
inserted_slices_ids.clear()
except Exception as ex2:
except Exception:
logger.error("delete_all_inserted_slices failed", exc_info=True)
raise ex2
raise
def delete_slice(slice_: Slice, do_commit: bool = False) -> None:
@@ -278,15 +278,15 @@ def delete_all_inserted_tables():
for table in tables_to_delete:
try:
delete_sqltable(table, False)
except Exception as ex:
except Exception:
logger.error(f"failed to delete {table.id}", exc_info=True)
raise ex
raise
if len(inserted_sqltables_ids) > 0:
db.session.commit()
inserted_sqltables_ids.clear()
except Exception as ex2:
except Exception:
logger.error("delete_all_inserted_tables failed", exc_info=True)
raise ex2
raise
def delete_sqltable(table: SqlaTable, do_commit: bool = False) -> None:
@@ -313,15 +313,15 @@ def delete_all_inserted_dbs():
for database in databases_to_delete:
try:
delete_database(database, False)
except Exception as ex:
except Exception:
logger.error(f"failed to delete {database.id}", exc_info=True)
raise ex
raise
if len(inserted_databases_ids) > 0:
db.session.commit()
inserted_databases_ids.clear()
except Exception as ex2:
except Exception:
logger.error("delete_all_inserted_databases failed", exc_info=True)
raise ex2
raise
def delete_database(database: Database, do_commit: bool = False) -> None: