Skip to content

Commit 8ca3cd6

Browse files
author
fazalpsinfo-cmyk
authored
fix: upgrade bare excepts across 5 files (#80)
1 parent 9badd32 commit 8ca3cd6

5 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/chatdbg/assistant/assistant.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ def _check_model(self):
139139
raise AssistantError(textwrap.dedent(f"""\
140140
The {self._model} model does not support function calls.
141141
You must use a model that does, eg. gpt-4."""))
142-
except:
142+
except AssistantError:
143+
raise
144+
except Exception:
143145
raise AssistantError(textwrap.dedent(f"""\
144146
{self._model} does not appear to be a supported model.
145147
See https://docs.litellm.ai/docs/providers."""))

src/chatdbg/chatdbg_gdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def _initial_prompt_error_message(self):
224224
with open(RUST_PANIC_LOG_FILENAME, "r") as log:
225225
panic_log = log.read()
226226
last_error_type = panic_log + "\n" + last_error_type
227-
except:
227+
except OSError:
228228
pass
229229
return last_error_type
230230

src/chatdbg/chatdbg_pdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def _getval_except(self, arg, frame=None):
308308
return sandbox_eval(arg, self.curframe.f_globals, self.curframe_locals)
309309
else:
310310
return sandbox_eval(arg, frame.f_globals, frame.f_locals)
311-
except:
311+
except Exception:
312312
exc_info = sys.exc_info()[:2]
313313
err = traceback.format_exception_only(*exc_info)[-1].strip()
314314
return "** raised %s **" % err
@@ -346,7 +346,7 @@ def do_info(self, arg):
346346
try:
347347
obj = eval(x, self.curframe.f_globals, self.curframe_locals)
348348
break # found something so we're good
349-
except:
349+
except Exception:
350350
# fail silently, try the next name
351351
pass
352352

src/chatdbg/pdb_util/locals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _extract_locals(frame: FrameType) -> set[str]:
4545
parameter_symbols.discard(None)
4646

4747
return (finder.defined_symbols | parameter_symbols) & locals.keys()
48-
except:
48+
except Exception:
4949
# ipes
5050
return set()
5151

src/chatdbg/util/printer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, out, debugger_prompt, chat_prefix, width):
1212
self._chat_prefix = chat_prefix
1313
try:
1414
self._width = min(width, os.get_terminal_size().columns - len(chat_prefix))
15-
except:
15+
except OSError:
1616
# get_terminal_size() may fail in notebooks
1717
self._width = width
1818

0 commit comments

Comments
 (0)