Skip to content

Commit 220afd1

Browse files
Potential fixes for 3 code quality findings (#41)
* Apply suggested fix to recline/repl/shell.py from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Apply suggested fix to recline/repl/shell.py from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Apply suggested fix to recline/repl/shell.py from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent 63cc989 commit 220afd1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

recline/repl/shell.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def relax(
7272

7373
_setup_repl(program_name, prompt, history_file, argv)
7474

75-
if single_command or not repl_mode or argv and len(argv) >= 2 and argv[1] == "-c":
75+
has_dash_c = (argv and len(argv) >= 2 and argv[1] == "-c")
76+
if single_command or not repl_mode or has_dash_c:
7677
# Some external process sent us a command to run (like scp or ssh or
7778
# so run it and exit
7879
command = argv[2:]
@@ -297,12 +298,16 @@ def setup_tab_complete() -> None:
297298
"""Set up the readline library to hook into our command completer"""
298299

299300
readline.set_completer_delims("")
300-
if sys.platform == "linux":
301+
if sys.platform.startswith("linux"):
301302
# pyreadline3 (used for windows) doesn't implement this
302303
# libedit (default for macos) implements this but never calls it (broken)
303304
readline.set_completion_display_matches_hook(completer.match_command_hook)
304305
readline.set_completer(completer.CommandCompleter(commands.COMMAND_REGISTRY).completer)
305-
if readline.__doc__ and "libedit" in readline.__doc__:
306+
# Heuristic backend detection: libedit is typically advertised in the module docstring.
307+
# Keep this centralized and defensive to avoid direct fragile checks.
308+
readline_doc = getattr(readline, "__doc__", "") or ""
309+
is_libedit = "libedit" in readline_doc.lower()
310+
if is_libedit:
306311
# macos doesn't use GNU readline, but BSD libedit instead
307312
readline.parse_and_bind("bind '\t' rl_complete")
308313
readline.parse_and_bind("bind '^R' em-inc-search-prev")

0 commit comments

Comments
 (0)