Skip to content

feat: support executables passed to ipdb3#284

Open
iloveitaly wants to merge 1 commit intogotcha:masterfrom
iloveitaly:support-executables
Open

feat: support executables passed to ipdb3#284
iloveitaly wants to merge 1 commit intogotcha:masterfrom
iloveitaly:support-executables

Conversation

@iloveitaly
Copy link
Contributor

@iloveitaly iloveitaly commented Aug 9, 2024

For instance, if your project has a script section a bin/ entry in your venv
will be generated. It's helpful to be able to pass the command reference to
ipdb for debugging.

Summary by CodeRabbit

Release Notes

  • New Features
    • The debugger now supports resolving executables from your system PATH, allowing you to launch sessions by passing executable names directly without specifying full file paths.

For instance, if your project has a script section a bin/ entry in your venv
will be generated. It's helpful to be able to pass the command reference to
ipdb for debugging.
@iloveitaly
Copy link
Contributor Author

@gotcha reminder here! Would love to have this merged in.

@iloveitaly
Copy link
Contributor Author

@gotcha ping!

@iloveitaly
Copy link
Contributor Author

@gotcha ping on this!

@gotcha
Copy link
Owner

gotcha commented Feb 27, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

The change adds support for resolving executables from the system PATH when ipdb is invoked with a file argument. It imports which from shutil and applies path resolution before checking file existence in the main() function.

Changes

Cohort / File(s) Summary
PATH resolution support
ipdb/__main__.py
Added which import from shutil and integrated PATH resolution in main() to resolve executable names when the provided mainpyfile argument is not found as a direct path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A path through the woods, now easy to find,
No more lost executables left behind,
With which in our pocket and PATH on our side,
ipdb hops forward with confident stride!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for passing executables to ipdb3, which aligns with the PR's objective of allowing executable/command references from venv bin/ entries to be debugged.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ipdb/__main__.py`:
- Around line 304-311: The code calls which(mainpyfile) and then passes
mainpyfile to os.path.exists without checking for None; update the logic around
the which() call so you only reassign mainpyfile if which(...) returned a
non-None path (or otherwise handle a None return) before calling
os.path.exists(mainpyfile), and ensure the error path (the print and sys.exit(1)
after the run_as_module check) handles the None case cleanly; also fix the
comment from "a executable" to "an executable". Use the existing symbols
mainpyfile, which(...), run_as_module, os.path.exists, print(...), and sys.exit
to locate where to change the code.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 400e37c and ae526fb.

📒 Files selected for processing (1)
  • ipdb/__main__.py

Comment on lines +304 to 311

# a executable command in $PATH may be passed
if not os.path.exists(mainpyfile):
mainpyfile = which(mainpyfile)

if not run_as_module and not os.path.exists(mainpyfile):
print("Error:", mainpyfile, "does not exist")
sys.exit(1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

which() returning None causes TypeError crash.

When the provided argument is neither an existing file nor a valid executable in PATH, which() returns None. This causes os.path.exists(mainpyfile) on line 309 to raise TypeError since os.path.exists() does not accept None.

Additionally, the comment has a minor grammar issue: "a executable" → "an executable".

🐛 Proposed fix to handle None from which()
     mainpyfile = args[0]  # Get script filename

-    # a executable command in $PATH may be passed
+    # an executable command in $PATH may be passed
     if not os.path.exists(mainpyfile):
-        mainpyfile = which(mainpyfile)
+        resolved = which(mainpyfile)
+        if resolved is not None:
+            mainpyfile = resolved

     if not run_as_module and not os.path.exists(mainpyfile):
         print("Error:", mainpyfile, "does not exist")
         sys.exit(1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# a executable command in $PATH may be passed
if not os.path.exists(mainpyfile):
mainpyfile = which(mainpyfile)
if not run_as_module and not os.path.exists(mainpyfile):
print("Error:", mainpyfile, "does not exist")
sys.exit(1)
# an executable command in $PATH may be passed
if not os.path.exists(mainpyfile):
resolved = which(mainpyfile)
if resolved is not None:
mainpyfile = resolved
if not run_as_module and not os.path.exists(mainpyfile):
print("Error:", mainpyfile, "does not exist")
sys.exit(1)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ipdb/__main__.py` around lines 304 - 311, The code calls which(mainpyfile)
and then passes mainpyfile to os.path.exists without checking for None; update
the logic around the which() call so you only reassign mainpyfile if which(...)
returned a non-None path (or otherwise handle a None return) before calling
os.path.exists(mainpyfile), and ensure the error path (the print and sys.exit(1)
after the run_as_module check) handles the None case cleanly; also fix the
comment from "a executable" to "an executable". Use the existing symbols
mainpyfile, which(...), run_as_module, os.path.exists, print(...), and sys.exit
to locate where to change the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants