jlevy / jlevy/repren

--dry-run with --renames creates directories as side effect

Open
#48 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
374
Forks
39
Avg merge
3m
Merged PRs (30d)
1

Description

## Summary

When using \`--dry-run\` with rename operations, \`make_parent_dirs()\` is called for the temp file path, which creates directories on disk even though dry-run mode should not modify the filesystem.

## Details

In \`repren.py\` at line 831-833, there is an existing TODO:

\`\`\`python
# TODO: This will create a directory even in dry_run mode, but perhaps that's acceptable.
# https://github.com/jlevy/repren/issues/6
make_parent_dirs(temp_path)
\`\`\`

This is related to the existing issue #6 (\"Nondestructive mode can create empty directories\") but is a distinct code path — issue #6 is about the temp file write creating parent dirs, while this is specifically about \`--dry-run\` violating the \"no modifications\" contract.

## Impact

- Users running \`--dry-run\` to safely preview changes may be surprised that directories are actually created
- In CI/CD pipelines or automated tooling, \`--dry-run\` is expected to be purely read-only

## Suggestion

Guard the \`make_parent_dirs()\` call with a dry-run check, or defer directory creation until after the dry-run check:

\`\`\`python
if not dry_run:
make_parent_dirs(temp_path)
\`\`\`

Note: This requires restructuring the temp file write logic slightly, since the temp file write is currently needed even in dry-run mode to compute tallies. An alternative is to compute tallies in memory without writing to disk in dry-run mode.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.