| 327 | return findings |
| 328 | |
| 329 | def check_python_syntax(self) -> list[Finding]: |
| 330 | findings: list[Finding] = [] |
| 331 | for path in self.git_files("*.py"): |
| 332 | full_path = self.repo_root / path |
| 333 | if not full_path.is_file() or "__pycache__" in path.parts: |
| 334 | continue |
| 335 | try: |
| 336 | ast.parse(full_path.read_text(encoding="utf-8"), filename=str(path)) |
| 337 | except SyntaxError as exc: |
| 338 | findings.append( |
| 339 | Finding( |
| 340 | "python-syntax", |
| 341 | path, |
| 342 | exc.msg, |
| 343 | line=exc.lineno, |
| 344 | ), |
| 345 | ) |
| 346 | except UnicodeDecodeError as exc: |
| 347 | findings.append(Finding("python-syntax", path, f"could not decode as UTF-8: {exc}")) |
| 348 | return findings |
| 349 | |
| 350 | def check_node_package_locks(self) -> list[Finding]: |
| 351 | findings: list[Finding] = [] |