Skip to content

Commit f3d6575

Browse files
authored
Use Exception. (#652)
1 parent 90fb7cc commit f3d6575

11 files changed

Lines changed: 32 additions & 32 deletions

File tree

datashuttle/configs/load_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def attempt_load_configs(
5555
try:
5656
new_cfg.load_from_file()
5757

58-
except BaseException:
58+
except Exception:
5959
new_cfg = None
6060

6161
utils.log_and_raise_error(

datashuttle/tui/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def handle_open_filesystem_browser(self, path_: Path) -> None:
193193

194194
try:
195195
showinfm.show_in_file_manager(path_.as_posix())
196-
except BaseException:
196+
except Exception:
197197
if path_.is_file():
198198
# I don't see why this is not working as according to docs it
199199
# should open the containing folder and select.
@@ -256,7 +256,7 @@ def rename_file_or_folder(self, path_, new_name) -> None:
256256
)
257257
self.screen.update_active_tab_tree()
258258

259-
except BaseException as e:
259+
except Exception as e:
260260
self.show_modal_error_dialog(
261261
f"Could not rename the file or folder."
262262
f"Check the new name is valid, and correct "

datashuttle/tui/interface.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def select_existing_project(self, project_name: str) -> InterfaceOutput:
5656
self.project = project
5757
return True, None
5858

59-
except BaseException as e:
59+
except Exception as e:
6060
return False, str(e)
6161

6262
def setup_new_project(
@@ -82,7 +82,7 @@ def setup_new_project(
8282

8383
return True, None
8484

85-
except BaseException as e:
85+
except Exception as e:
8686
return False, str(e)
8787

8888
def set_configs_on_existing_project(
@@ -102,7 +102,7 @@ def set_configs_on_existing_project(
102102
self.project.update_config_file(**cfg_kwargs)
103103
return True, None
104104

105-
except BaseException as e:
105+
except Exception as e:
106106
return False, str(e)
107107

108108
def create_folders(
@@ -145,7 +145,7 @@ def create_folders(
145145
)
146146
return True, None
147147

148-
except BaseException as e:
148+
except Exception as e:
149149
return False, str(e)
150150

151151
def validate_names(
@@ -192,7 +192,7 @@ def validate_names(
192192
"format_ses": format_ses,
193193
}
194194

195-
except BaseException as e:
195+
except Exception as e:
196196
return False, str(e)
197197

198198
def validate_project(
@@ -237,7 +237,7 @@ def validate_project(
237237
)
238238
return True, results
239239

240-
except BaseException as e:
240+
except Exception as e:
241241
return False, str(e)
242242

243243
# Transfer
@@ -268,7 +268,7 @@ def transfer_entire_project(self, upload: bool) -> InterfaceOutput:
268268

269269
return True, None
270270

271-
except BaseException as e:
271+
except Exception as e:
272272
return False, str(e)
273273

274274
def transfer_top_level_only(
@@ -311,7 +311,7 @@ def transfer_top_level_only(
311311

312312
return True, None
313313

314-
except BaseException as e:
314+
except Exception as e:
315315
return False, str(e)
316316

317317
def transfer_custom_selection(
@@ -362,7 +362,7 @@ def transfer_custom_selection(
362362

363363
return True, None
364364

365-
except BaseException as e:
365+
except Exception as e:
366366
return False, str(e)
367367

368368
# Name templates
@@ -394,7 +394,7 @@ def set_validation_templates(
394394
self.validation_templates = validation_templates
395395
return True, None
396396

397-
except BaseException as e:
397+
except Exception as e:
398398
return False, str(e)
399399

400400
def get_tui_settings(self) -> Dict:
@@ -467,7 +467,7 @@ def get_next_sub(
467467
include_central=include_central,
468468
)
469469
return True, next_sub
470-
except BaseException as e:
470+
except Exception as e:
471471
return False, str(e)
472472

473473
def get_next_ses(
@@ -482,7 +482,7 @@ def get_next_ses(
482482
include_central=include_central,
483483
)
484484
return True, next_ses
485-
except BaseException as e:
485+
except Exception as e:
486486
return False, str(e)
487487

488488
def get_ssh_hostkey(self) -> InterfaceOutput:
@@ -492,7 +492,7 @@ def get_ssh_hostkey(self) -> InterfaceOutput:
492492
self.project.cfg["central_host_id"]
493493
)
494494
return True, key
495-
except BaseException as e:
495+
except Exception as e:
496496
return False, str(e)
497497

498498
def save_hostkey_locally(self, key: paramiko.RSAKey) -> InterfaceOutput:
@@ -505,7 +505,7 @@ def save_hostkey_locally(self, key: paramiko.RSAKey) -> InterfaceOutput:
505505
)
506506
return True, None
507507

508-
except BaseException as e:
508+
except Exception as e:
509509
return False, str(e)
510510

511511
def setup_key_pair_and_rclone_config(
@@ -528,7 +528,7 @@ def setup_key_pair_and_rclone_config(
528528

529529
return True, None
530530

531-
except BaseException as e:
531+
except Exception as e:
532532
return False, str(e)
533533

534534
# Setup Google Drive
@@ -562,7 +562,7 @@ def setup_gdrive_connection(
562562
)
563563

564564
return True, None
565-
except BaseException as e:
565+
except Exception as e:
566566
return False, str(e)
567567

568568
def get_rclone_message_for_gdrive_without_browser(
@@ -577,7 +577,7 @@ def get_rclone_message_for_gdrive_without_browser(
577577
log=False,
578578
)
579579
return True, output
580-
except BaseException as e:
580+
except Exception as e:
581581
return False, str(e)
582582

583583
def terminate_gdrive_setup(self) -> None:
@@ -625,5 +625,5 @@ def setup_aws_connection(
625625
)
626626
aws.raise_if_bucket_absent(self.project.cfg)
627627
return True, None
628-
except BaseException as e:
628+
except Exception as e:
629629
return False, str(e)

datashuttle/utils/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def strip_uncheckable_names(
12101210
prefix,
12111211
return_as_int=return_as_int, # type: ignore
12121212
)[0]
1213-
except BaseException:
1213+
except Exception:
12141214
continue
12151215

12161216
if path_:

tests/tests_integration/test_logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def test_clear_logging_path(self, clean_project_name, tmp_path):
379379

380380
configs["local_path"] = "~"
381381

382-
with pytest.raises(BaseException):
382+
with pytest.raises(Exception):
383383
project.make_config_file(**configs)
384384

385385
# Because an error was raised, the log will stay in the
@@ -446,7 +446,7 @@ def test_validate_project_logging(self, project):
446446
test_utils.delete_log_files(project.cfg.logging_path)
447447

448448
# Check a validation error is logged.
449-
with pytest.raises(BaseException) as e:
449+
with pytest.raises(Exception) as e:
450450
project.validate_project("rawdata", display_mode="error")
451451

452452
log = test_utils.read_log_file(project.cfg.logging_path)
@@ -475,7 +475,7 @@ def test_validate_names_against_project_logging(self, project):
475475
project.create_folders("rawdata", "sub-001")
476476
test_utils.delete_log_files(project.cfg.logging_path) #
477477

478-
with pytest.raises(BaseException) as e:
478+
with pytest.raises(Exception) as e:
479479
project.create_folders("rawdata", "sub-001_id-a")
480480

481481
log = test_utils.read_log_file(project.cfg.logging_path)

tests/tests_integration/test_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_bypass_validation(self, project):
153153

154154
project = test_utils.make_project(project.project_name)
155155

156-
with pytest.raises(BaseException) as e:
156+
with pytest.raises(Exception) as e:
157157
project.create_folders("rawdata", "sub-@@@")
158158

159159
assert (

tests/tests_tui/test_tui_datatypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def test_select_displayed_datatypes_create(
135135
)
136136

137137
# Confirm also that narrow datatypes are not shown.
138-
with pytest.raises(BaseException):
138+
with pytest.raises(Exception):
139139
pilot.app.screen.query_one(
140140
f"#create_{narrow_datatype_names[0]}_checkbox"
141141
)

tests/tests_tui/test_tui_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def test_show_transfer_tree_status(self, setup_project_paths):
6969
is False
7070
)
7171

72-
with pytest.raises(BaseException) as e:
72+
with pytest.raises(Exception) as e:
7373
transfer_tab.query_one("#transfer_legend")
7474

7575
assert "No nodes match" in str(e)

tests/tests_tui/test_tui_widgets_and_defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def test_existing_project_configs(self, setup_project_paths):
267267
"#configs_name_label",
268268
"#configs_name_input",
269269
]:
270-
with pytest.raises(BaseException) as e:
270+
with pytest.raises(Exception) as e:
271271
configs_content.query_one(id)
272272
assert "No nodes match" in str(e)
273273

tests/tests_unit/test_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_get_max_sub_or_ses_num_and_value_length_error(self, prefix):
168168
f"{prefix}-003",
169169
]
170170

171-
with pytest.raises(BaseException) as e:
171+
with pytest.raises(Exception) as e:
172172
getters.get_max_sub_or_ses_num_and_value_length(
173173
bad_num_values_names, prefix
174174
)

0 commit comments

Comments
 (0)