From 1aa07660763db1e83b717447a76189935c058e85 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Thu, 6 Jul 2023 19:58:10 +0200 Subject: [PATCH 1/3] prevent D004 false positive for windows users --- src/doc8/checks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc8/checks.py b/src/doc8/checks.py index a43d1a7..4b0dfeb 100644 --- a/src/doc8/checks.py +++ b/src/doc8/checks.py @@ -61,11 +61,13 @@ def report_iter(self, line): class CheckCarriageReturn(ContentCheck): + _CARRIAGE_RETURN_REGEX = re.compile(r'\r(?!\n)') REPORTS = frozenset(["D004"]) def report_iter(self, parsed_file): for i, line in enumerate(parsed_file.lines): - if b"\r" in line: + matches = self._CARRIAGE_RETURN_REGEX.findall(line) + if len(matches) != 0: yield (i + 1, "D004", "Found literal carriage return") From 8dc7637eba19ed50d75ba09f477158a6ef6af7b8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:59:11 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/doc8/checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc8/checks.py b/src/doc8/checks.py index 4b0dfeb..34fe2b8 100644 --- a/src/doc8/checks.py +++ b/src/doc8/checks.py @@ -61,7 +61,7 @@ def report_iter(self, line): class CheckCarriageReturn(ContentCheck): - _CARRIAGE_RETURN_REGEX = re.compile(r'\r(?!\n)') + _CARRIAGE_RETURN_REGEX = re.compile(r"\r(?!\n)") REPORTS = frozenset(["D004"]) def report_iter(self, parsed_file): From 3154208f077b30f8d9b52a83e58607b687e8be45 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Thu, 6 Jul 2023 20:11:41 +0200 Subject: [PATCH 3/3] use a byte regex --- src/doc8/checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc8/checks.py b/src/doc8/checks.py index 34fe2b8..8ece687 100644 --- a/src/doc8/checks.py +++ b/src/doc8/checks.py @@ -61,7 +61,7 @@ def report_iter(self, line): class CheckCarriageReturn(ContentCheck): - _CARRIAGE_RETURN_REGEX = re.compile(r"\r(?!\n)") + _CARRIAGE_RETURN_REGEX = re.compile(rb"\r(?!\n)") REPORTS = frozenset(["D004"]) def report_iter(self, parsed_file):