Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/check_unicode/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down