Skip to content
Open
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
2 changes: 1 addition & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def convert_arg_line_to_args(self, arg_line: str) -> list[str]:
"allow skipping of regions of Python code using "
"begin/end comments one could use: "
"--ignore-multiline-regex "
"'# codespell:ignore-begin *\\n.*# codespell:ignore-end *\\n'. "
"'# codespell:ignore-begin *\\n.*?# codespell:ignore-end *\\n'. "
"Defaults to empty/disabled.",
)
parser.add_argument(
Expand Down
15 changes: 15 additions & 0 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,21 @@ def test_ignore_multiline_regex_option(
"""
assert fname.read_text() == fixed_text

# The documented example uses a non-greedy match so a typo between two
# ignore regions is still reported (a greedy .* would swallow it).
two_blocks = """
# codespell:ignore-begin
abandonned
# codespell:ignore-end
abandonned
# codespell:ignore-begin
abandonned
# codespell:ignore-end
"""
fname.write_text(two_blocks)
documented = r"# codespell:ignore-begin *\n.*?# codespell:ignore-end *\n"
assert cs.main(fname, "--ignore-multiline-regex", documented) == 1


def test_uri_regex_option(
tmp_path: Path,
Expand Down