Skip to content

Commit f589404

Browse files
committed
Enable ruff BLE ruleset
1 parent 3f7f318 commit f589404

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

cmd2/cmd2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ def complete( # type: ignore[override]
22552255
ansi.style_aware_write(sys.stdout, '\n' + err_str + '\n')
22562256
rl_force_redisplay()
22572257
return None
2258-
except Exception as ex:
2258+
except Exception as ex: # noqa: BLE001
22592259
# Insert a newline so the exception doesn't print in the middle of the command line being tab completed
22602260
self.perror()
22612261
self.pexcept(ex)
@@ -2562,7 +2562,7 @@ def onecmd_plus_hooks(
25622562
stop = True
25632563
except PassThroughException as ex:
25642564
raise ex.wrapped_ex
2565-
except Exception as ex:
2565+
except Exception as ex: # noqa: BLE001
25662566
self.pexcept(ex)
25672567
finally:
25682568
try:
@@ -2576,7 +2576,7 @@ def onecmd_plus_hooks(
25762576
stop = True
25772577
except PassThroughException as ex:
25782578
raise ex.wrapped_ex
2579-
except Exception as ex:
2579+
except Exception as ex: # noqa: BLE001
25802580
self.pexcept(ex)
25812581

25822582
return stop
@@ -4131,7 +4131,7 @@ def do_set(self, args: argparse.Namespace) -> None:
41314131
try:
41324132
orig_value = settable.get_value()
41334133
settable.set_value(utils.strip_quotes(args.value))
4134-
except Exception as ex:
4134+
except ValueError as ex:
41354135
self.perror(f"Error setting {args.param}: {ex}")
41364136
else:
41374137
self.poutput(f"{args.param} - was: {orig_value!r}\nnow: {settable.get_value()!r}")
@@ -4425,7 +4425,7 @@ def py_quit() -> None:
44254425
if py_code_to_run:
44264426
try:
44274427
interp.runcode(py_code_to_run) # type: ignore[arg-type]
4428-
except BaseException:
4428+
except BaseException: # noqa: BLE001
44294429
# We don't care about any exception that happened in the Python code
44304430
pass
44314431

@@ -4448,7 +4448,7 @@ def py_quit() -> None:
44484448
# Since quit() or exit() raise an EmbeddedConsoleExit, interact() exits before printing
44494449
# the exitmsg. Therefore, we will not provide it one and print it manually later.
44504450
interp.interact(banner=banner, exitmsg='')
4451-
except BaseException:
4451+
except BaseException: # noqa: BLE001
44524452
# We don't care about any exception that happened in the interactive console
44534453
pass
44544454
finally:

examples/python_scripting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def do_cd(self, arglist) -> None:
7777
else:
7878
try:
7979
os.chdir(path)
80-
except Exception as ex:
80+
except Exception as ex: # noqa: BLE001
8181
err = f'{ex}'
8282
else:
8383
self.poutput(f'Successfully changed directory to {path}')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ select = [
162162
# "ARG", # flake8-unused-arguments (functions or methods with arguments that are never used)
163163
"ASYNC", # flake8-async (async await bugs)
164164
# "B", # flake8-bugbear (various likely bugs and design issues)
165-
# "BLE", # flake8-blind-except (force more specific exception types than just Exception)
165+
"BLE", # flake8-blind-except (force more specific exception types than just Exception)
166166
"C4", # flake8-comprehensions (warn about things that could be written as a comprehensions but aren't)
167167
"C90", # McCabe cyclomatic complexity (warn about functions that are too complex)
168168
"COM", # flake8-commas (forces commas at the end of every type of iterable/container

tests/test_cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ def test_pipe_to_shell_error(base_app) -> None:
771771
# ValueError for headless Linux systems without Gtk installed
772772
# AssertionError can be raised by paste_klipper().
773773
# PyperclipException for pyperclip-specific exceptions
774-
except Exception:
774+
except Exception: # noqa: BLE001
775775
can_paste = False
776776
else:
777777
can_paste = True

0 commit comments

Comments
 (0)