Skip to content

Commit

Permalink
Enforce --write-changes in interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MercuryDemo authored and DimitriPapadopoulos committed Jul 26, 2024
1 parent a28e3c7 commit f83ef1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,9 @@ def main(*args: str) -> int:
for ifile, cfg_file in enumerate(used_cfg_files, start=1):
print(f" {ifile}: {cfg_file}")

if options.interactive > 0:
options.write_changes = True

if options.regex and options.write_changes:
return _usage_error(
parser,
Expand Down
2 changes: 0 additions & 2 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ def test_interactivity(
cs.main("-i", "-1", fname)
assert e.type is SystemExit
assert e.value.code != 0
with FakeStdin("y\n"):
assert cs.main("-i", "3", fname) == 1
with FakeStdin("n\n"):
result = cs.main("-w", "-i", "3", fname, std=True)
assert isinstance(result, tuple)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ max-complexity = 45
[tool.ruff.lint.pylint]
allow-magic-value-types = ["bytes", "int", "str",]
max-args = 13
max-branches = 47
max-branches = 48
max-returns = 12
max-statements = 119

0 comments on commit f83ef1e

Please sign in to comment.