Parse *source* and return all KBI violations found.
(path: str, source: str)
| 236 | |
| 237 | |
| 238 | def check_file(path: str, source: str) -> list[Violation]: |
| 239 | """Parse *source* and return all KBI violations found.""" |
| 240 | try: |
| 241 | tree = ast.parse(source, filename=path) |
| 242 | except SyntaxError: |
| 243 | return [] |
| 244 | visitor = TryExceptVisitor(source_lines=source.splitlines()) |
| 245 | visitor.visit(tree) |
| 246 | return visitor.violations |
| 247 | |
| 248 | |
| 249 | def collect_python_files( |