From: Štěpán Balážik Date: Tue, 27 Jan 2026 21:31:30 +0000 (+0100) Subject: Issue errors on re.compile only when isctest is imported X-Git-Tag: v9.21.19~15^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4684c9c0914817751561d359a0b441c325294e09;p=thirdparty%2Fbind9.git Issue errors on re.compile only when isctest is imported This is in preparation of running pylint on more parts of the codebase. --- diff --git a/bin/tests/system/re_compile_checker.py b/bin/tests/system/re_compile_checker.py index efa0e9a038c..5dd214f18e5 100644 --- a/bin/tests/system/re_compile_checker.py +++ b/bin/tests/system/re_compile_checker.py @@ -36,10 +36,19 @@ class ReCompileChecker(BaseRawFileChecker): def process_module(self, node: nodes.Module) -> None: pattern = re.compile(r"re\.compile\(") + import_pattern = re.compile(r"^\s*(import|from)\s+isctest\b") with node.stream() as stream: - for lineno, line in enumerate(stream): - if pattern.search(line.decode("utf-8")): - self.add_message("re-compile-alias", line=lineno) + lines = [line.decode("utf-8", errors="replace") for line in stream] + + if not any( + import_pattern.search(line) and not line.lstrip().startswith("#") + for line in lines + ): + return + + for lineno, line in enumerate(lines): + if pattern.search(line): + self.add_message("re-compile-alias", line=lineno) def register(linter: PyLinter) -> None: