Add --recursive option for explicit directory traversal#4
Conversation
- Add -r/--recursive flag to CLI options - Implement collect_files_from_directory() helper function - Update file collection logic to handle directories with recursive flag - Ensures consistent behavior across shells (bash vs pwsh) Fixes #3 Co-authored-by: kompre <kompre@users.noreply.github.com>
Code Review - PR #4: Add --recursive option for explicit directory traversalSummaryThis PR successfully addresses issue #3 by implementing a Code Quality & Best Practices ✓Strengths:
Suggestions:
Potential Bugs & IssuesCritical Issue Found:
Minor Issues:
Performance ConsiderationsOverall: Good performance characteristics
Potential optimization:
Security ConcernsLow Risk - No major security issues Minor considerations:
Test Coverage
|
|
@claude create new issues based on the code review. |
|
Claude finished @kompre's task —— View job Unable to Create Issues DirectlyI've analyzed the code review and identified the following issues that should be created, but I don't have permission to create GitHub issues using the Recommended Issues to Create:Issue 1: Add warning messages for skipped/invalid pathsPriority: Medium Description: Problem: # else: path might be from shell glob expansion that doesn't exist anymore, skip itThis silently skips invalid paths without warning the user. If a user provides a path that doesn't exist or isn't a file/directory with the right extension, they get no feedback. Proposed Solution: else:
# Path doesn't exist or doesn't match criteria
if not os.path.exists(path):
click.echo(f"Warning: Path does not exist: {path}", err=True)
elif path.endswith(input_extension):
click.echo(f"Warning: Path exists but is not a file or directory: {path}", err=True)Issue 2: Add error handling for directory access in collect_files_from_directoryPriority: Medium Description: Problem: Proposed Solution: else:
try:
for item in os.listdir(directory):
item_path = os.path.join(directory, item)
if os.path.isfile(item_path) and item.endswith(extension):
files.append(item_path)
except PermissionError:
click.echo(f"Warning: Permission denied accessing directory: {directory}", err=True)Issue 3: Add test coverage for --recursive flagPriority: High Description: Missing Test Cases:
Recommended Test Example: def test_directory_with_recursive(setup_teardown_test_env):
"""Test that --recursive flag processes subdirectories."""
runner = CliRunner()
test_dir = setup_teardown_test_env
# Create nested structure
nested_dir = os.path.join(test_dir, "notebooks", "subfolder")
os.makedirs(nested_dir, exist_ok=True)
shutil.copy("tests/assets/__test.ipynb",
os.path.join(nested_dir, "nested.ipynb"))
result = runner.invoke(convert_files, [test_dir, "-r"])
assert result.exit_code == 0
assert "nested.ipynb" in result.outputIssue 4: Update documentation for --recursive flagPriority: Medium Description: Missing Updates:
Suggested Addition to Docstring: Issue 5: Consider refactoring to use pathlib for cleaner path handlingPriority: Low Description: Potential Benefits:
Example Refactor for collect_files_from_directory: from pathlib import Path
def collect_files_from_directory(directory, extension, recursive=False):
directory = Path(directory)
if recursive:
return [str(p) for p in directory.rglob(f"*{extension}")]
return [str(p) for p in directory.glob(f"*{extension}") if p.is_file()]Note: This is a nice-to-have enhancement, not blocking. Issue 6: Document or configure symlink handling behaviorPriority: Low Description: Questions to Address:
Suggestion: SummaryI've identified 6 issues from the code review:
You'll need to create these issues manually or grant the necessary permissions for me to create them using the |
Implements the
--recursiveoption to enable consistent directory traversal across different shells.Fixes #3
Changes
-r/--recursiveflag to CLI optionscollect_files_from_directory()helper functionThis ensures the tool behaves consistently regardless of the shell being used (bash vs PowerShell).
Generated with Claude Code