Skip to content

Commit 6b844c6

Browse files
committed
fix: force string format in CSV output to prevent spreadsheet truncation
1 parent 632e3da commit 6b844c6

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

scripts/version_scanner/tests/unit/test_version_scanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def test_write_csv_report(tmp_path):
156156
assert rows[0]["file_path"] == "./setup.py"
157157
assert rows[0]["rule_name"] == "python_requires_check"
158158
assert rows[0]["line_number"] == "1"
159-
assert rows[0]["matched_string"] == "python_requires = '>=3.7'"
159+
assert rows[0]["matched_string"] == '="python_requires = \'>=3.7\'"'
160160
assert rows[0]["context_line"] == "python_requires = '>=3.7'"
161161

162162

@@ -513,7 +513,7 @@ def test_main_stdout(capsys):
513513
assert "=== CSV Output ===" in captured.out
514514
assert "test.py," in captured.out
515515
assert "test," in captured.out
516-
assert "3.7" in captured.out
516+
assert '="3.7"' in captured.out
517517

518518
def test_scan_file_truncation_bug(tmp_path):
519519
"""Test that searching for 3.1 does NOT match 3.10 (truncation bug)."""

scripts/version_scanner/version_scanner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def format_match_for_csv(
225225
context = formatted.get("context_line", "")
226226
matched = formatted.get("matched_string", "")
227227

228+
# Force spreadsheet apps (Google Sheets, Excel) to treat the match as a string.
229+
# Otherwise, they parse "3.10" as a number and drop the trailing zero, displaying "3.1".
230+
if matched:
231+
formatted["matched_string"] = f'="{matched}"'
232+
228233
if len(context) > 500:
229234
match_start = context.find(matched)
230235
if match_start != -1:

0 commit comments

Comments
 (0)