Remove string literals and single-line comments from a line for analysis.
(line: str)
| 72 | |
| 73 | |
| 74 | def _strip_strings_and_comments(line: str) -> str: |
| 75 | """Remove string literals and single-line comments from a line for analysis.""" |
| 76 | # Remove string literals (simple approach) |
| 77 | result = re.sub(r'"[^"\\]*(?:\\.[^"\\]*)*"', '""', line) |
| 78 | # Remove single-line comments but preserve suppression check on original |
| 79 | comment_match = _RE_LINE_COMMENT.search(result) |
| 80 | if comment_match: |
| 81 | result = result[: comment_match.start()] |
| 82 | return result |
| 83 | |
| 84 | |
| 85 | class BareUsingChecker(FileContentChecker): |
no test coverage detected