Skip to content

Commit af27368

Browse files
committed
fix: suppress SyntaxWarning from ast.parse on regex-heavy files
1 parent 72c6691 commit af27368

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • src/treemapper/diffctx/edges/semantic

src/treemapper/diffctx/edges/semantic/python.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ def _resolve_relative(name: str, source_path: Path, repo_root: Path | None) -> s
5252

5353
def _extract_imports_from_content(content: str, source_path: Path | None = None, repo_root: Path | None = None) -> set[str]:
5454
imports: set[str] = set()
55+
import warnings
56+
5557
try:
56-
tree = ast.parse(content)
58+
with warnings.catch_warnings():
59+
warnings.simplefilter("ignore", SyntaxWarning)
60+
tree = ast.parse(content)
5761
except SyntaxError:
5862
return imports
5963

0 commit comments

Comments
 (0)