Skip to content

Commit ddcfea5

Browse files
stonebigclaude
andcommitted
comment the stderr notes too
They describe a requirements file and someone will eventually fold both streams into one; a "# " costs nothing there and reads the same in a terminal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 4be3d32 commit ddcfea5

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

README_PYPI.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ redirection leaves them behind:
104104

105105
```console
106106
$ wppm requirements_slim.txt -tl -t D:\WPy64\python > requirements_slim_new.txt
107-
160 entries -> 112 kept, 48 already pulled in
108-
8 repeated, collapsed: brotli, openai, pympler, pytest, python-barcode, ...
107+
# 160 entries -> 112 kept, 48 already pulled in
108+
# 8 repeated, collapsed: brotli, openai, pympler, pytest, python-barcode, ...
109109
```
110110

111+
Those two lines are commented although they go to stderr, so folding both streams into
112+
one file (`> new.txt 2>&1`) still leaves a file pip can read.
113+
111114
The notes the source file carried are kept, since they are its author's. `-v` adds the
112115
reasoning: where the list came from, and every dropped entry commented out with what
113116
pulls it in, so re-asking for one is uncommenting it.

tests/test_top_level.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ def test_source_notes_are_kept_even_plainly(self, pip):
155155
class TestSummary:
156156
def test_counts_what_happened(self, pip):
157157
notes = wppm_module.top_level_summary(pip.top_level(["app", "lib", "orphan"]))
158-
assert "3 entries -> 2 kept, 1 already pulled in" in notes[0]
158+
assert notes[0] == "# 3 entries -> 2 kept, 1 already pulled in"
159+
160+
def test_every_note_is_a_comment(self, pip):
161+
"""stdout and stderr may well end up in the same file."""
162+
notes = wppm_module.top_level_summary(pip.top_level(["orphan", "orphan", "nosuchpackage"]))
163+
assert len(notes) == 3
164+
assert all(note.startswith("# ") for note in notes)
159165

160166
def test_reports_repeats(self, pip):
161167
notes = wppm_module.top_level_summary(pip.top_level(["orphan", "orphan"]))

wppm/wppm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,18 @@ def top_level_as_requirements(result, comments=(), source=None, verbose=False):
306306
return lines
307307

308308
def top_level_summary(result):
309-
"""What the caller should know about the answer, rather than of it."""
309+
"""What the caller should know about the answer, rather than of it.
310+
311+
Commented, though it goes to stderr: someone will fold the two streams
312+
into one file sooner or later, and a comment costs nothing.
313+
"""
310314
kept, dropped = result["kept"], result["dropped"]
311315
notes = [f"{len(kept) + len(dropped)} entries -> {len(kept)} kept, {len(dropped)} already pulled in"]
312316
if result["duplicates"]:
313317
notes.append(f"{len(result['duplicates'])} repeated, collapsed: {few(result['duplicates'], 12)}")
314318
if result["unknown"]:
315319
notes.append(f"{len(result['unknown'])} not installed in the target, so left unresolved: {few(result['unknown'])}")
316-
return notes
320+
return [f"# {note}" for note in notes]
317321

318322
def main(test=False):
319323
# package summaries may contain characters the console codepage can't encode (emoji): don't crash

0 commit comments

Comments
 (0)