From 65333a0078d2de752f66af5db1500155639028eb Mon Sep 17 00:00:00 2001 From: mit-d Date: Mon, 23 Feb 2026 12:35:09 -0700 Subject: [PATCH 1/2] fix: --fix mode now fixes all files, not just the first any() short-circuits on the first True, so fix_file was never called on files after the first one that needed fixing. Use a list comprehension to force evaluation of all files. --- src/check_unicode/main.py | 3 ++- tests/test_cli.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/check_unicode/main.py b/src/check_unicode/main.py index 9995630..041fe9c 100644 --- a/src/check_unicode/main.py +++ b/src/check_unicode/main.py @@ -472,7 +472,8 @@ def main(argv: list[str] | None = None) -> int: # Fix mode if args.fix: - any_fixed = any(fix_file(filepath) for filepath in files) + fixed = [fix_file(filepath) for filepath in files] + any_fixed = any(fixed) all_findings = _scan_files(files, allow, do_confusables=do_confusables) if all_findings: print_findings(all_findings, no_color=args.no_color, quiet=args.quiet) diff --git a/tests/test_cli.py b/tests/test_cli.py index f13ff99..62cc037 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -60,6 +60,16 @@ def test_fix_clean_file_exits_0(self, tmp_path: Path) -> None: f.write_text("hello world\n", encoding="utf-8") assert main(["--fix", str(f)]) == 0 + def test_fix_multiple_files_all_fixed(self, tmp_path: Path) -> None: + """Fix mode fixes all files, not just the first one.""" + f1 = tmp_path / "a.txt" + f2 = tmp_path / "b.txt" + f1.write_text("He said \u201chello\u201d\n", encoding="utf-8") + f2.write_text("word\u2014word\n", encoding="utf-8") + assert main(["--fix", str(f1), str(f2)]) == 1 + assert f1.read_text(encoding="utf-8") == 'He said "hello"\n' + assert f2.read_text(encoding="utf-8") == "word--word\n" + def test_fix_dangerous_still_reported(self, tmp_path: Path) -> None: """Fix mode does not remove dangerous characters.""" f = tmp_path / "bidi.txt" From 65d829e50a34778263741e2168d4087d9d19aa8b Mon Sep 17 00:00:00 2001 From: mit-d Date: Mon, 23 Feb 2026 12:36:46 -0700 Subject: [PATCH 2/2] docs: add changelog entry for --fix multi-file bug --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c9e9dc..c565b76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Unreleased + +### Fixed + +- `--fix` mode now fixes all files, not just the first (`any()` short-circuited + after the first fixable file, skipping the rest) + ## 0.3.2 - 2026-02-21 ### Added